Introduce globalsym_addr.

This is an instruction used in legalization of GlobalVarData::Sym global
variables.
This commit is contained in:
Dan Gohman
2017-10-30 10:02:29 -07:00
parent cb805f704d
commit 9c54c3fff0
11 changed files with 96 additions and 9 deletions

View File

@@ -389,6 +389,14 @@ global_addr = Instruction(
""",
ins=GV, outs=addr)
# A specialized form of global_addr instructions that only handles
# symbolic names.
globalsym_addr = Instruction(
'globalsym_addr', r"""
Compute the address of global variable GV, which is a symbolic name.
""",
ins=GV, outs=addr)
#
# WebAssembly bounds-checked heap accesses.
#

View File

@@ -271,6 +271,13 @@ I32.enc(base.func_addr.i32, *r.allones_fnaddr4(0xb8),
I64.enc(base.func_addr.i64, *r.allones_fnaddr8.rex(0xb8, w=1),
isap=allones_funcaddrs)
#
# Global addresses.
#
I32.enc(base.globalsym_addr.i32, *r.gvaddr4(0xb8))
I64.enc(base.globalsym_addr.i64, *r.gvaddr8.rex(0xb8, w=1))
#
# Call/return
#

View File

@@ -9,7 +9,7 @@ from base.formats import Unary, UnaryImm, Binary, BinaryImm, MultiAry
from base.formats import Trap, Call, IndirectCall, Store, Load
from base.formats import IntCompare, FloatCompare, IntCond, FloatCond
from base.formats import Jump, Branch, BranchInt, BranchFloat
from base.formats import Ternary, FuncAddr
from base.formats import Ternary, FuncAddr, UnaryGlobalVar
from base.formats import RegMove, RegSpill, RegFill
from .registers import GPR, ABCD, FPR, GPR8, FPR8, FLAG, StackGPR32, StackFPR32
from .defs import supported_floatccs
@@ -510,6 +510,24 @@ allones_fnaddr8 = TailRecipe(
sink.put8(!0);
''')
# XX+rd id with Abs4 globalsym relocation.
gvaddr4 = TailRecipe(
'gvaddr4', UnaryGlobalVar, size=4, ins=(), outs=GPR,
emit='''
PUT_OP(bits | (out_reg0 & 7), rex1(out_reg0), sink);
sink.reloc_globalsym(RelocKind::Abs4.into(), global_var);
sink.put4(0);
''')
# XX+rd iq with Abs8 globalsym relocation.
gvaddr8 = TailRecipe(
'gvaddr8', UnaryGlobalVar, size=8, ins=(), outs=GPR,
emit='''
PUT_OP(bits | (out_reg0 & 7), rex1(out_reg0), sink);
sink.reloc_globalsym(RelocKind::Abs8.into(), global_var);
sink.put8(0);
''')
#
# Store recipes.
#