Skip to content

Commit 25bf532

Browse files
committed
big veriisle squash
1 parent 098430f commit 25bf532

File tree

219 files changed

+53728
-2453
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

219 files changed

+53728
-2453
lines changed

Cargo.lock

Lines changed: 563 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ members = [
135135
"cranelift",
136136
"cranelift/isle/fuzz",
137137
"cranelift/isle/islec",
138+
"cranelift/isle/veri/aslp",
139+
"cranelift/isle/veri/isaspec",
140+
"cranelift/isle/veri/meta",
141+
"cranelift/isle/veri/test-macros",
142+
"cranelift/isle/veri/veri",
138143
"cranelift/serde",
139144
"crates/bench-api",
140145
"crates/c-api/artifact",
@@ -321,6 +326,7 @@ hyper = "1.0.1"
321326
http = "1.0.0"
322327
http-body = "1.0.0"
323328
http-body-util = "0.1.0"
329+
reqwest = "0.11"
324330
bytes = "1.4"
325331
futures = { version = "0.3.27", default-features = false }
326332
indexmap = { version = "2.0.0", default-features = false }

cranelift/codegen/build.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,14 @@ fn build_isle(
171171

172172
let mut had_error = false;
173173
for compilation in &isle_compilations.items {
174-
for file in &compilation.inputs {
174+
for file in &compilation.tracked_inputs {
175175
println!("cargo:rerun-if-changed={}", file.display());
176176
}
177177

178178
if let Err(e) = run_compilation(compilation) {
179179
had_error = true;
180180
eprintln!("Error building ISLE files:");
181-
eprintln!("{e:?}");
181+
eprintln!("{e}");
182182
#[cfg(not(feature = "isle-errors"))]
183183
{
184184
eprintln!("To see a more detailed error report, run: ");
@@ -209,11 +209,11 @@ fn run_compilation(compilation: &IsleCompilation) -> Result<(), Errors> {
209209

210210
let code = {
211211
let file_paths = compilation
212-
.inputs
213-
.iter()
214-
.chain(compilation.untracked_inputs.iter());
212+
.paths()
213+
.map_err(|e| Errors::from_io(e, "list isle compilation file paths"))?;
215214

216215
let mut options = isle::codegen::CodegenOptions::default();
216+
options.rule_trace = compilation.rule_trace;
217217
// Because we include!() the generated ISLE source, we cannot
218218
// put the global pragmas (`#![allow(...)]`) in the ISLE
219219
// source itself; we have to put them in the source that

cranelift/codegen/meta/src/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ impl Error {
1818
}
1919
}
2020

21+
impl std::error::Error for Error {}
22+
2123
impl fmt::Display for Error {
2224
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2325
write!(f, "{}", self.inner)

cranelift/codegen/meta/src/gen_isle.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,13 @@ fn gen_common_isle(
220220
continue;
221221
}
222222

223+
let has_ty_param = !inst.format.has_value_list && inst.value_results.len() >= 1;
224+
223225
fmtln!(
224226
fmt,
225227
"(decl {} ({}{}) {})",
226228
inst.name,
227-
match isle_target {
228-
IsleTarget::Lower => "",
229-
IsleTarget::Opt => "Type ",
230-
},
229+
if has_ty_param { "Type " } else { "" },
231230
inst.operands_in
232231
.iter()
233232
.map(|o| {
@@ -242,16 +241,14 @@ fn gen_common_isle(
242241
.join(" "),
243242
ret_ty
244243
);
244+
fmtln!(fmt, "(attr {} (tag clif_{}))", inst.name, inst.name);
245245
fmtln!(fmt, "(extractor");
246246
fmt.indent(|fmt| {
247247
fmtln!(
248248
fmt,
249249
"({} {}{})",
250250
inst.name,
251-
match isle_target {
252-
IsleTarget::Lower => "",
253-
IsleTarget::Opt => "ty ",
254-
},
251+
if has_ty_param { "ty " } else { "" },
255252
inst.operands_in
256253
.iter()
257254
.map(|o| { o.name })
@@ -260,11 +257,8 @@ fn gen_common_isle(
260257
);
261258

262259
let mut s = format!(
263-
"(inst_data{} (InstructionData.{} (Opcode.{})",
264-
match isle_target {
265-
IsleTarget::Lower => "",
266-
IsleTarget::Opt => " ty",
267-
},
260+
"(inst_data {} (InstructionData.{} (Opcode.{})",
261+
if has_ty_param { "ty" } else { "_" },
268262
inst.format.name,
269263
inst.camel_name
270264
);

cranelift/codegen/meta/src/isle.rs

Lines changed: 95 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::io::Result;
2+
13
/// A list of compilations (transformations from ISLE source to
24
/// generated Rust source) that exist in the repository.
35
///
@@ -11,11 +13,62 @@ pub struct IsleCompilations {
1113
pub items: Vec<IsleCompilation>,
1214
}
1315

16+
impl IsleCompilations {
17+
pub fn lookup(&self, name: &str) -> Option<&IsleCompilation> {
18+
for compilation in &self.items {
19+
if compilation.name == name {
20+
return Some(compilation);
21+
}
22+
}
23+
None
24+
}
25+
}
26+
1427
#[derive(Clone, Debug)]
1528
pub struct IsleCompilation {
29+
pub name: String,
1630
pub output: std::path::PathBuf,
17-
pub inputs: Vec<std::path::PathBuf>,
31+
pub tracked_inputs: Vec<std::path::PathBuf>,
1832
pub untracked_inputs: Vec<std::path::PathBuf>,
33+
pub rule_trace: bool,
34+
}
35+
36+
impl IsleCompilation {
37+
/// All inputs to the computation, tracked or untracked. May contain directories.
38+
pub fn inputs(&self) -> Vec<std::path::PathBuf> {
39+
self.tracked_inputs
40+
.iter()
41+
.chain(self.untracked_inputs.iter())
42+
.cloned()
43+
.collect()
44+
}
45+
46+
/// All path inputs to the compilation. Directory inputs are expanded to the
47+
/// list of all ISLE files in the directory.
48+
pub fn paths(&self) -> Result<Vec<std::path::PathBuf>> {
49+
let mut paths = Vec::new();
50+
for input in self.inputs() {
51+
paths.extend(Self::expand_paths(&input)?);
52+
}
53+
Ok(paths)
54+
}
55+
56+
fn expand_paths(input: &std::path::PathBuf) -> Result<Vec<std::path::PathBuf>> {
57+
if input.is_file() {
58+
return Ok(vec![input.clone()]);
59+
}
60+
61+
let mut paths = Vec::new();
62+
for entry in std::fs::read_dir(input)? {
63+
let path = entry?.path();
64+
if let Some(ext) = path.extension() {
65+
if ext == "isle" {
66+
paths.push(path);
67+
}
68+
}
69+
}
70+
Ok(paths)
71+
}
1972
}
2073

2174
/// Construct the list of compilations (transformations from ISLE
@@ -30,6 +83,11 @@ pub fn get_isle_compilations(
3083
let prelude_isle = codegen_crate_dir.join("src").join("prelude.isle");
3184
let prelude_opt_isle = codegen_crate_dir.join("src").join("prelude_opt.isle");
3285
let prelude_lower_isle = codegen_crate_dir.join("src").join("prelude_lower.isle");
86+
let prelude_spec_isle = codegen_crate_dir.join("src").join("prelude_spec.isle");
87+
let inst_specs_isle = codegen_crate_dir.join("src").join("inst_specs.isle");
88+
let inst_tags_isle = codegen_crate_dir.join("src").join("inst_tags.isle");
89+
let fpconst_isle = codegen_crate_dir.join("src").join("fpconst.isle");
90+
let state_isle = codegen_crate_dir.join("src").join("state.isle");
3391

3492
// Directory for mid-end optimizations.
3593
let src_opts = codegen_crate_dir.join("src").join("opts");
@@ -61,10 +119,14 @@ pub fn get_isle_compilations(
61119
items: vec![
62120
// The mid-end optimization rules.
63121
IsleCompilation {
122+
name: "opt".to_string(),
64123
output: gen_dir.join("isle_opt.rs"),
65-
inputs: vec![
124+
tracked_inputs: vec![
66125
prelude_isle.clone(),
67126
prelude_opt_isle,
127+
prelude_spec_isle.clone(),
128+
inst_specs_isle.clone(),
129+
inst_tags_isle.clone(),
68130
src_opts.join("arithmetic.isle"),
69131
src_opts.join("bitops.isle"),
70132
src_opts.join("cprop.isle"),
@@ -78,64 +140,90 @@ pub fn get_isle_compilations(
78140
src_opts.join("vector.isle"),
79141
],
80142
untracked_inputs: vec![clif_opt_isle],
143+
rule_trace: false,
81144
},
82145
// The x86-64 instruction selector.
83146
IsleCompilation {
147+
name: "x64".to_string(),
84148
output: gen_dir.join("isle_x64.rs"),
85-
inputs: vec![
149+
tracked_inputs: vec![
86150
prelude_isle.clone(),
87151
prelude_lower_isle.clone(),
152+
prelude_spec_isle.clone(),
153+
inst_specs_isle.clone(),
154+
inst_tags_isle.clone(),
88155
src_isa_x64.join("inst.isle"),
89156
src_isa_x64.join("lower.isle"),
90157
],
91158
untracked_inputs: vec![clif_lower_isle.clone()],
159+
rule_trace: false,
92160
},
93161
// The aarch64 instruction selector.
94162
IsleCompilation {
163+
name: "aarch64".to_string(),
95164
output: gen_dir.join("isle_aarch64.rs"),
96-
inputs: vec![
165+
tracked_inputs: vec![
97166
prelude_isle.clone(),
98167
prelude_lower_isle.clone(),
168+
prelude_spec_isle.clone(),
169+
inst_specs_isle.clone(),
170+
inst_tags_isle.clone(),
171+
fpconst_isle.clone(),
172+
state_isle.clone(),
99173
src_isa_aarch64.join("inst.isle"),
100174
src_isa_aarch64.join("inst_neon.isle"),
175+
src_isa_aarch64.join("spec"),
101176
src_isa_aarch64.join("lower.isle"),
102177
src_isa_aarch64.join("lower_dynamic_neon.isle"),
103178
],
104179
untracked_inputs: vec![clif_lower_isle.clone()],
180+
rule_trace: true,
105181
},
106182
// The s390x instruction selector.
107183
IsleCompilation {
184+
name: "s390x".to_string(),
108185
output: gen_dir.join("isle_s390x.rs"),
109-
inputs: vec![
186+
tracked_inputs: vec![
110187
prelude_isle.clone(),
111188
prelude_lower_isle.clone(),
189+
prelude_spec_isle.clone(),
190+
inst_specs_isle.clone(),
191+
inst_tags_isle.clone(),
112192
src_isa_s390x.join("inst.isle"),
113193
src_isa_s390x.join("lower.isle"),
114194
],
115195
untracked_inputs: vec![clif_lower_isle.clone()],
196+
rule_trace: false,
116197
},
117198
// The risc-v instruction selector.
118199
IsleCompilation {
200+
name: "riscv64".to_string(),
119201
output: gen_dir.join("isle_riscv64.rs"),
120-
inputs: vec![
202+
tracked_inputs: vec![
121203
prelude_isle.clone(),
122204
prelude_lower_isle.clone(),
205+
prelude_spec_isle.clone(),
206+
inst_specs_isle.clone(),
207+
inst_tags_isle.clone(),
123208
src_isa_risc_v.join("inst.isle"),
124209
src_isa_risc_v.join("inst_vector.isle"),
125210
src_isa_risc_v.join("lower.isle"),
126211
],
127212
untracked_inputs: vec![clif_lower_isle.clone()],
213+
rule_trace: false,
128214
},
129215
// The Pulley instruction selector.
130216
IsleCompilation {
217+
name: "pulley".to_string(),
131218
output: gen_dir.join("isle_pulley_shared.rs"),
132-
inputs: vec![
219+
tracked_inputs: vec![
133220
prelude_isle.clone(),
134221
prelude_lower_isle.clone(),
135222
src_isa_pulley_shared.join("inst.isle"),
136223
src_isa_pulley_shared.join("lower.isle"),
137224
],
138225
untracked_inputs: vec![clif_lower_isle.clone()],
226+
rule_trace: false,
139227
},
140228
],
141229
}

cranelift/codegen/src/fpconst.isle

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
;; GENERATED BY `fpconst`. DO NOT EDIT!!!
2+
3+
; Build one as a floating-point of the given width.
4+
(macro (fp_one w)
5+
(conv_to w
6+
(switch w
7+
(32 #x000000003f800000)
8+
(64 #x3ff0000000000000)
9+
)
10+
)
11+
)
12+
13+
; Build negative one as a floating-point of the given width.
14+
(macro (fp_minus_one w)
15+
(conv_to w
16+
(switch w
17+
(32 #x00000000bf800000)
18+
(64 #xbff0000000000000)
19+
)
20+
)
21+
)
22+
23+
; Build half as a floating-point of the given width.
24+
(macro (fp_half w)
25+
(conv_to w
26+
(switch w
27+
(32 #x000000003f000000)
28+
(64 #x3fe0000000000000)
29+
)
30+
)
31+
)
32+
33+
; Build negative half as a floating-point of the given width.
34+
(macro (fp_minus_half w)
35+
(conv_to w
36+
(switch w
37+
(32 #x00000000bf000000)
38+
(64 #xbfe0000000000000)
39+
)
40+
)
41+
)
42+
43+
; Build 32-bit integer minimum as a floating-point of the given width.
44+
(macro (fp_i32_min w)
45+
(conv_to w
46+
(switch w
47+
(32 #x00000000cf000000)
48+
(64 #xc1e0000000000000)
49+
)
50+
)
51+
)
52+
53+
; Build negative 32-bit integer minimum as a floating-point of the given width.
54+
(macro (fp_minus_i32_min w)
55+
(conv_to w
56+
(switch w
57+
(32 #x000000004f000000)
58+
(64 #x41e0000000000000)
59+
)
60+
)
61+
)
62+
63+
; Build 64-bit integer minimum as a floating-point of the given width.
64+
(macro (fp_i64_min w)
65+
(conv_to w
66+
(switch w
67+
(32 #x00000000df000000)
68+
(64 #xc3e0000000000000)
69+
)
70+
)
71+
)
72+
73+
; Build negative 64-bit integer minimum as a floating-point of the given width.
74+
(macro (fp_minus_i64_min w)
75+
(conv_to w
76+
(switch w
77+
(32 #x000000005f000000)
78+
(64 #x43e0000000000000)
79+
)
80+
)
81+
)

0 commit comments

Comments
 (0)