Change GlobalVar to GlobalValue

This commit is contained in:
Lachlan Sneff
2018-06-14 01:07:27 -04:00
committed by Dan Gohman
parent 49cc693d64
commit 5c320a0d30
44 changed files with 324 additions and 237 deletions

View File

@@ -16,8 +16,8 @@ ebb = EntityRefKind(
#: A reference to a stack slot declared in the function preamble.
stack_slot = EntityRefKind('stack_slot', 'A stack slot.')
#: A reference to a global variable.
global_var = EntityRefKind('global_var', 'A global variable.')
#: A reference to a global valueiable.
global_value = EntityRefKind('global_value', 'A global value.')
#: A reference to a function sugnature declared in the function preamble.
#: This is used to provide the call signature in a call_indirect instruction.

View File

@@ -18,7 +18,7 @@ UnaryImm = InstructionFormat(imm64)
UnaryIeee32 = InstructionFormat(ieee32)
UnaryIeee64 = InstructionFormat(ieee64)
UnaryBool = InstructionFormat(boolean)
UnaryGlobalVar = InstructionFormat(entities.global_var)
UnaryGlobalValue = InstructionFormat(entities.global_value)
Binary = InstructionFormat(VALUE, VALUE)
BinaryImm = InstructionFormat(VALUE, imm64)
@@ -79,5 +79,5 @@ CondTrap = InstructionFormat(VALUE, trapcode)
IntCondTrap = InstructionFormat(intcc, VALUE, trapcode)
FloatCondTrap = InstructionFormat(floatcc, VALUE, trapcode)
# Finally extract the names of global variables in this module.
# Finally extract the names of global valueiables in this module.
InstructionFormat.extract_names(globals())

View File

@@ -491,19 +491,19 @@ stack_addr = Instruction(
# Global variables.
#
GV = Operand('GV', entities.global_var)
GV = Operand('GV', entities.global_value)
global_addr = Instruction(
'global_addr', r"""
Compute the address of global variable GV.
global_value = Instruction(
'global_value', r"""
Compute the value of global GV.
""",
ins=GV, outs=addr)
# A specialized form of global_addr instructions that only handles
# A specialized form of global_value instructions that only handles
# symbolic names.
globalsym_addr = Instruction(
'globalsym_addr', r"""
Compute the address of global variable GV, which is a symbolic name.
Compute the address of global GV, which is a symbolic name.
""",
ins=GV, outs=addr)

View File

@@ -62,7 +62,7 @@ expand_flags = XFormGroup('expand_flags', """
# Custom expansions for memory objects.
expand.custom_legalize(insts.global_addr, 'expand_global_addr')
expand.custom_legalize(insts.global_value, 'expand_global_value')
expand.custom_legalize(insts.heap_addr, 'expand_heap_addr')
# Custom expansions for calls.

View File

@@ -2,7 +2,7 @@
Cretonne predicates that consider `Function` fields.
"""
from cdsl.predicates import FieldPredicate
from .formats import UnaryGlobalVar, InstructionFormat
from .formats import UnaryGlobalValue, InstructionFormat
try:
from typing import TYPE_CHECKING
@@ -32,7 +32,7 @@ class IsColocatedData(FieldPredicate):
def __init__(self):
# type: () -> None
super(IsColocatedData, self).__init__(
UnaryGlobalVar.global_var, 'is_colocated_data', ('func',))
UnaryGlobalValue.global_value, 'is_colocated_data', ('func',))
class LengthEquals(FieldPredicate):

View File

@@ -53,7 +53,7 @@ call_conv = EnumSetting(
# Note that Cretonne doesn't currently need an is_pie flag, because PIE is just
# PIC where symbols can't be pre-empted, which can be expressed with the
# `colocated` flag on external functions and global variables.
# `colocated` flag on external functions and global valueiables.
is_pic = BoolSetting("Enable Position-Independent Code generation")
colocated_libcalls = BoolSetting(

View File

@@ -208,7 +208,7 @@ class InstructionFormat(object):
"""
Given a dict mapping name -> object as returned by `globals()`, find
all the InstructionFormat objects and set their name from the dict key.
This is used to name a bunch of global variables in a module.
This is used to name a bunch of global valueiables in a module.
"""
for name, obj in globs.items():
if isinstance(obj, InstructionFormat):

View File

@@ -365,7 +365,7 @@ class RegClass(object):
"""
Given a dict mapping name -> object as returned by `globals()`, find
all the RegClass objects and set their name from the dict key.
This is used to name a bunch of global variables in a module.
This is used to name a bunch of global valueiables in a module.
"""
for name, obj in globs.items():
if isinstance(obj, RegClass):

View File

@@ -14,7 +14,7 @@ from base.formats import IntCompare, IntCompareImm, FloatCompare
from base.formats import IntCond, FloatCond
from base.formats import IntSelect, IntCondTrap, FloatCondTrap
from base.formats import Jump, Branch, BranchInt, BranchFloat
from base.formats import Ternary, FuncAddr, UnaryGlobalVar
from base.formats import Ternary, FuncAddr, UnaryGlobalValue
from base.formats import RegMove, RegSpill, RegFill, CopySpecial
from base.formats import LoadComplex, StoreComplex
from .registers import GPR, ABCD, FPR, GPR_DEREF_SAFE, GPR_ZERO_DEREF_SAFE
@@ -703,50 +703,50 @@ got_fnaddr8 = TailRecipe(
# XX+rd id with Abs4 globalsym relocation.
gvaddr4 = TailRecipe(
'gvaddr4', UnaryGlobalVar, size=4, ins=(), outs=GPR,
'gvaddr4', UnaryGlobalValue, size=4, ins=(), outs=GPR,
emit='''
PUT_OP(bits | (out_reg0 & 7), rex1(out_reg0), sink);
sink.reloc_external(Reloc::Abs4,
&func.global_vars[global_var].symbol_name(),
&func.global_values[global_value].symbol_name(),
0);
sink.put4(0);
''')
# XX+rd iq with Abs8 globalsym relocation.
gvaddr8 = TailRecipe(
'gvaddr8', UnaryGlobalVar, size=8, ins=(), outs=GPR,
'gvaddr8', UnaryGlobalValue, size=8, ins=(), outs=GPR,
emit='''
PUT_OP(bits | (out_reg0 & 7), rex1(out_reg0), sink);
sink.reloc_external(Reloc::Abs8,
&func.global_vars[global_var].symbol_name(),
&func.global_values[global_value].symbol_name(),
0);
sink.put8(0);
''')
# XX+rd iq with PCRel4 globalsym relocation.
pcrel_gvaddr8 = TailRecipe(
'pcrel_gvaddr8', UnaryGlobalVar, size=5, ins=(), outs=GPR,
'pcrel_gvaddr8', UnaryGlobalValue, size=5, ins=(), outs=GPR,
emit='''
PUT_OP(bits, rex2(0, out_reg0), sink);
modrm_rm(5, out_reg0, sink);
// The addend adjusts for the difference between the end of the
// instruction and the beginning of the immediate field.
sink.reloc_external(Reloc::X86PCRel4,
&func.global_vars[global_var].symbol_name(),
&func.global_values[global_value].symbol_name(),
-4);
sink.put4(0);
''')
# XX+rd iq with Abs8 globalsym relocation.
got_gvaddr8 = TailRecipe(
'got_gvaddr8', UnaryGlobalVar, size=5, ins=(), outs=GPR,
'got_gvaddr8', UnaryGlobalValue, size=5, ins=(), outs=GPR,
emit='''
PUT_OP(bits, rex2(0, out_reg0), sink);
modrm_rm(5, out_reg0, sink);
// The addend adjusts for the difference between the end of the
// instruction and the beginning of the immediate field.
sink.reloc_external(Reloc::X86GOTPCRel4,
&func.global_vars[global_var].symbol_name(),
&func.global_values[global_value].symbol_name(),
-4);
sink.put4(0);
''')