mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-18 16:06:30 +08:00
compiler: Extract maximum alignment from target data layout
In particular, i64/double are actually supposed to be aligned to their size on RISC-V (at least according to the ELF psABI), though it is unclear to me whether this actually caused any issues.
This commit is contained in:
parent
a83f330d74
commit
23a4db494f
@ -177,6 +177,15 @@ class LLVMIRGenerator:
|
|||||||
self.empty_metadata = self.llmodule.add_metadata([])
|
self.empty_metadata = self.llmodule.add_metadata([])
|
||||||
self.quote_fail_msg = None
|
self.quote_fail_msg = None
|
||||||
|
|
||||||
|
# Maximum alignment required according to the target platform ABI. As this is
|
||||||
|
# not directly exposed by LLVM, just take the maximum across all the "big"
|
||||||
|
# elementary types we use. (Vector types, should we ever support them, are
|
||||||
|
# likely contenders for even larger alignment requirements.)
|
||||||
|
self.max_target_alignment = max(map(
|
||||||
|
lambda t: self.abi_layout_info.get_size_align(t)[1],
|
||||||
|
[lli64, lldouble, llptr]
|
||||||
|
))
|
||||||
|
|
||||||
def add_pred(self, pred, block):
|
def add_pred(self, pred, block):
|
||||||
if block not in self.llpred_map:
|
if block not in self.llpred_map:
|
||||||
self.llpred_map[block] = set()
|
self.llpred_map[block] = set()
|
||||||
@ -1529,7 +1538,7 @@ class LLVMIRGenerator:
|
|||||||
|
|
||||||
self.llbuilder.position_at_end(llalloc)
|
self.llbuilder.position_at_end(llalloc)
|
||||||
llalloca = self.llbuilder.alloca(lli8, llsize, name="rpc.alloc")
|
llalloca = self.llbuilder.alloca(lli8, llsize, name="rpc.alloc")
|
||||||
llalloca.align = 4 # maximum alignment required by OR1K ABI
|
llalloca.align = self.max_target_alignment
|
||||||
llphi.add_incoming(llalloca, llalloc)
|
llphi.add_incoming(llalloca, llalloc)
|
||||||
self.llbuilder.branch(llhead)
|
self.llbuilder.branch(llhead)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user