Made changes for review

This commit is contained in:
Lachlan Sneff
2018-06-15 15:35:53 -04:00
committed by Dan Gohman
parent 3686fc2fc7
commit 38ab82bcc0
4 changed files with 13 additions and 26 deletions

View File

@@ -110,7 +110,7 @@ Program structure
In LLVM IR, the largest representable unit is the *module* which corresponds
more or less to a C translation unit. It is a collection of functions and
global values that may contain references to external symbols too.
global variables that may contain references to external symbols too.
In Cretonne IR, the largest representable unit is the *function*. This is so
that functions can easily be compiled in parallel without worrying about

View File

@@ -554,21 +554,18 @@ stack overflow checks in the prologue.
the stack pointer has reached or exceeded the limit, generate a trap with a
``stk_ovf`` code.
The global value must be accessible and naturally aligned for a
pointer-sized value.
Setting `stack_limit` is an alternative way to detect stack overflow, when using
a calling convention that doesn't perform stack probes.
Global variables
----------------
Global values
-------------
A *global value* is an :term:`accessible` object in memory whose address is
not known at compile time. The address is computed at runtime by
:inst:`global_value`, possibly using information provided by the linker via
relocations. There are multiple kinds of global values using different
methods for determining their address. Cretonne does not track the type or even
the size of global values, they are just pointers to non-stack memory.
A *global value* is an object whose value is not known at compile time. The
value is computed at runtime by :inst:`global_value`, possibly using
information provided by the linker via relocations. There are multiple
kinds of global values using different methods for determining their value.
Cretonne does not track the type of a global value, for they are just
values stored in non-stack memory.
When Cretonne is generating code for a virtual machine environment, globals can
be used to access data structures in the VM's runtime. This requires functions

View File

@@ -6,7 +6,7 @@
use cursor::{Cursor, FuncCursor};
use flowgraph::ControlFlowGraph;
use ir::condcodes::IntCC;
use ir::{self, InstBuilder, MemFlags};
use ir::{self, InstBuilder};
use isa::TargetIsa;
/// Expand a `heap_addr` instruction according to the definition of the heap.
@@ -57,12 +57,7 @@ fn dynamic_addr(
pos.use_srcloc(inst);
// Start with the bounds check. Trap if `offset + size > bound`.
let bound_addr = pos.ins().global_value(addr_ty, bound_gv);
let mut mflags = MemFlags::new();
// The bound variable is requied to be accessible and aligned.
mflags.set_notrap();
mflags.set_aligned();
let bound = pos.ins().load(offset_ty, mflags, bound_addr, 0);
let bound = pos.ins().global_value(addr_ty, bound_gv);
let oob;
if size == 1 {
@@ -163,12 +158,7 @@ fn offset_addr(
match pos.func.heaps[heap].base {
ir::HeapBase::ReservedReg => unimplemented!(),
ir::HeapBase::GlobalValue(base_gv) => {
let base_addr = pos.ins().global_value(addr_ty, base_gv);
let mut mflags = MemFlags::new();
// The base address variable is requied to be accessible and aligned.
mflags.set_notrap();
mflags.set_aligned();
let base = pos.ins().load(addr_ty, mflags, base_addr, 0);
let base = pos.ins().global_value(addr_ty, base_gv);
pos.func.dfg.replace(inst).iadd(base, offset);
}
}

View File

@@ -93,7 +93,7 @@ pub trait FuncEnvironment {
///
/// The index space covers both imported globals and globals defined by the module.
///
/// Return the global value reference that should be used to access the global and the
/// Return the global variable reference that should be used to access the global and the
/// WebAssembly type of the global.
fn make_global(&mut self, func: &mut ir::Function, index: GlobalIndex) -> GlobalValue;