1 use crate::cdsl::settings::{SettingGroup, SettingGroupBuilder}; 2 3 pub(crate) fn define() -> SettingGroup { 4 let mut settings = SettingGroupBuilder::new("shared"); 5 6 settings.add_enum( 7 "regalloc", 8 "Register allocator to use with the MachInst backend.", 9 r#" 10 This selects the register allocator as an option among those offered by the `regalloc.rs` 11 crate. Please report register allocation bugs to the maintainers of this crate whenever 12 possible. 13 14 Note: this only applies to target that use the MachInst backend. As of 2020-04-17, this 15 means the x86_64 backend doesn't use this yet. 16 17 Possible values: 18 19 - `backtracking` is a greedy, backtracking register allocator as implemented in 20 Spidermonkey's optimizing tier IonMonkey. It may take more time to allocate registers, but 21 it should generate better code in general, resulting in better throughput of generated 22 code. 23 - `backtracking_checked` is the backtracking allocator with additional self checks that may 24 take some time to run, and thus these checks are disabled by default. 25 - `experimental_linear_scan` is an experimental linear scan allocator. It may take less 26 time to allocate registers, but generated code's quality may be inferior. As of 27 2020-04-17, it is still experimental and it should not be used in production settings. 28 - `experimental_linear_scan_checked` is the linear scan allocator with additional self 29 checks that may take some time to run, and thus these checks are disabled by default. 30 "#, 31 vec![ 32 "backtracking", 33 "backtracking_checked", 34 "experimental_linear_scan", 35 "experimental_linear_scan_checked", 36 ], 37 ); 38 39 settings.add_enum( 40 "opt_level", 41 "Optimization level for generated code.", 42 r#" 43 Supported levels: 44 45 - `none`: Minimise compile time by disabling most optimizations. 46 - `speed`: Generate the fastest possible code 47 - `speed_and_size`: like "speed", but also perform transformations aimed at reducing code size. 48 "#, 49 vec!["none", "speed", "speed_and_size"], 50 ); 51 52 settings.add_bool( 53 "enable_verifier", 54 "Run the Cranelift IR verifier at strategic times during compilation.", 55 r#" 56 This makes compilation slower but catches many bugs. The verifier is always enabled by 57 default, which is useful during development. 58 "#, 59 true, 60 ); 61 62 // Note that Cranelift doesn't currently need an is_pie flag, because PIE is 63 // just PIC where symbols can't be pre-empted, which can be expressed with the 64 // `colocated` flag on external functions and global values. 65 settings.add_bool( 66 "is_pic", 67 "Enable Position-Independent Code generation.", 68 "", 69 false, 70 ); 71 72 settings.add_bool( 73 "use_colocated_libcalls", 74 "Use colocated libcalls.", 75 r#" 76 Generate code that assumes that libcalls can be declared "colocated", 77 meaning they will be defined along with the current function, such that 78 they can use more efficient addressing. 79 "#, 80 false, 81 ); 82 83 settings.add_bool( 84 "avoid_div_traps", 85 "Generate explicit checks around native division instructions to avoid their trapping.", 86 r#" 87 This is primarily used by SpiderMonkey which doesn't install a signal 88 handler for SIGFPE, but expects a SIGILL trap for division by zero. 89 90 On ISAs like ARM where the native division instructions don't trap, 91 this setting has no effect - explicit checks are always inserted. 92 "#, 93 false, 94 ); 95 96 settings.add_bool( 97 "enable_float", 98 "Enable the use of floating-point instructions.", 99 r#" 100 Disabling use of floating-point instructions is not yet implemented. 101 "#, 102 true, 103 ); 104 105 settings.add_bool( 106 "enable_nan_canonicalization", 107 "Enable NaN canonicalization.", 108 r#" 109 This replaces NaNs with a single canonical value, for users requiring 110 entirely deterministic WebAssembly computation. This is not required 111 by the WebAssembly spec, so it is not enabled by default. 112 "#, 113 false, 114 ); 115 116 settings.add_bool( 117 "enable_pinned_reg", 118 "Enable the use of the pinned register.", 119 r#" 120 This register is excluded from register allocation, and is completely under the control of 121 the end-user. It is possible to read it via the get_pinned_reg instruction, and to set it 122 with the set_pinned_reg instruction. 123 "#, 124 false, 125 ); 126 127 settings.add_bool( 128 "use_pinned_reg_as_heap_base", 129 "Use the pinned register as the heap base.", 130 r#" 131 Enabling this requires the enable_pinned_reg setting to be set to true. It enables a custom 132 legalization of the `heap_addr` instruction so it will use the pinned register as the heap 133 base, instead of fetching it from a global value. 134 135 Warning! Enabling this means that the pinned register *must* be maintained to contain the 136 heap base address at all times, during the lifetime of a function. Using the pinned 137 register for other purposes when this is set is very likely to cause crashes. 138 "#, 139 false, 140 ); 141 142 settings.add_bool( 143 "enable_simd", 144 "Enable the use of SIMD instructions.", 145 "", 146 false, 147 ); 148 149 settings.add_bool( 150 "enable_atomics", 151 "Enable the use of atomic instructions", 152 "", 153 true, 154 ); 155 156 settings.add_bool( 157 "enable_safepoints", 158 "Enable safepoint instruction insertions.", 159 r#" 160 This will allow the emit_stack_maps() function to insert the safepoint 161 instruction on top of calls and interrupt traps in order to display the 162 live reference values at that point in the program. 163 "#, 164 false, 165 ); 166 167 settings.add_enum( 168 "tls_model", 169 "Defines the model used to perform TLS accesses.", 170 "", 171 vec!["none", "elf_gd", "macho", "coff"], 172 ); 173 174 // Settings specific to the `baldrdash` calling convention. 175 176 settings.add_enum( 177 "libcall_call_conv", 178 "Defines the calling convention to use for LibCalls call expansion.", 179 r#" 180 This may be different from the ISA default calling convention. 181 182 The default value is to use the same calling convention as the ISA 183 default calling convention. 184 185 This list should be kept in sync with the list of calling 186 conventions available in isa/call_conv.rs. 187 "#, 188 vec![ 189 "isa_default", 190 "fast", 191 "cold", 192 "system_v", 193 "windows_fastcall", 194 "apple_aarch64", 195 "baldrdash_system_v", 196 "baldrdash_windows", 197 "baldrdash_2020", 198 "probestack", 199 ], 200 ); 201 202 settings.add_num( 203 "baldrdash_prologue_words", 204 "Number of pointer-sized words pushed by the baldrdash prologue.", 205 r#" 206 Functions with the `baldrdash` calling convention don't generate their 207 own prologue and epilogue. They depend on externally generated code 208 that pushes a fixed number of words in the prologue and restores them 209 in the epilogue. 210 211 This setting configures the number of pointer-sized words pushed on the 212 stack when the Cranelift-generated code is entered. This includes the 213 pushed return address on x86. 214 "#, 215 0, 216 ); 217 218 settings.add_bool( 219 "enable_llvm_abi_extensions", 220 "Enable various ABI extensions defined by LLVM's behavior.", 221 r#" 222 In some cases, LLVM's implementation of an ABI (calling convention) 223 goes beyond a standard and supports additional argument types or 224 behavior. This option instructs Cranelift codegen to follow LLVM's 225 behavior where applicable. 226 227 Currently, this applies only to Windows Fastcall on x86-64, and 228 allows an `i128` argument to be spread across two 64-bit integer 229 registers. The Fastcall implementation otherwise does not support 230 `i128` arguments, and will panic if they are present and this 231 option is not set. 232 "#, 233 false, 234 ); 235 236 settings.add_bool( 237 "unwind_info", 238 "Generate unwind information.", 239 r#" 240 This increases metadata size and compile time, but allows for the 241 debugger to trace frames, is needed for GC tracing that relies on 242 libunwind (such as in Wasmtime), and is unconditionally needed on 243 certain platforms (such as Windows) that must always be able to unwind. 244 "#, 245 true, 246 ); 247 248 // BaldrMonkey requires that not-yet-relocated function addresses be encoded 249 // as all-ones bitpatterns. 250 settings.add_bool( 251 "emit_all_ones_funcaddrs", 252 "Emit not-yet-relocated function addresses as all-ones bit patterns.", 253 "", 254 false, 255 ); 256 257 // Stack probing options. 258 259 settings.add_bool( 260 "enable_probestack", 261 "Enable the use of stack probes for supported calling conventions.", 262 "", 263 true, 264 ); 265 266 settings.add_bool( 267 "probestack_func_adjusts_sp", 268 "Enable if the stack probe adjusts the stack pointer.", 269 "", 270 false, 271 ); 272 273 settings.add_num( 274 "probestack_size_log2", 275 "The log2 of the size of the stack guard region.", 276 r#" 277 Stack frames larger than this size will have stack overflow checked 278 by calling the probestack function. 279 280 The default is 12, which translates to a size of 4096. 281 "#, 282 12, 283 ); 284 285 // Jump table options. 286 287 settings.add_bool( 288 "enable_jump_tables", 289 "Enable the use of jump tables in generated machine code.", 290 "", 291 true, 292 ); 293 294 // Spectre options. 295 296 settings.add_bool( 297 "enable_heap_access_spectre_mitigation", 298 "Enable Spectre mitigation on heap bounds checks.", 299 r#" 300 This is a no-op for any heap that needs no bounds checks; e.g., 301 if the limit is static and the guard region is large enough that 302 the index cannot reach past it. 303 304 This option is enabled by default because it is highly 305 recommended for secure sandboxing. The embedder should consider 306 the security implications carefully before disabling this option. 307 "#, 308 true, 309 ); 310 311 settings.build() 312 } 313