forked from OSchip/llvm-project
[mips] Changed the way symbols are handled in dla and la instructions to allow simple expressions.
Summary: An instruction like "(d)la $5, symbol+8" previously would have crashed the assembler as it contains an expression. This is now fixed. A few tests cases have also been changed to reflect these changes, however these should only be syntax changes. Some new test cases have also been added. Patch by Scott Egerton. Reviewers: vkalintiris, dsanders Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12760 llvm-svn: 249311
This commit is contained in:
parent
268b51a188
commit
d5a89418c5
|
@ -2341,14 +2341,11 @@ bool MipsAsmParser::loadAndAddSymbolAddress(
|
|||
SMLoc IDLoc, SmallVectorImpl<MCInst> &Instructions) {
|
||||
warnIfNoMacro(IDLoc);
|
||||
|
||||
// FIXME: The way we're handling symbols right now prevents simple expressions
|
||||
// like foo+8. We'll be able to fix this once our unary operators (%hi
|
||||
// and similar) are treated as operators rather than as fixup types.
|
||||
const MCSymbolRefExpr *Symbol = cast<MCSymbolRefExpr>(SymExpr);
|
||||
const MCSymbolRefExpr *HiExpr = MCSymbolRefExpr::create(
|
||||
&Symbol->getSymbol(), MCSymbolRefExpr::VK_Mips_ABS_HI, getContext());
|
||||
const MCSymbolRefExpr *LoExpr = MCSymbolRefExpr::create(
|
||||
&Symbol->getSymbol(), MCSymbolRefExpr::VK_Mips_ABS_LO, getContext());
|
||||
const MCExpr *Symbol = cast<MCExpr>(SymExpr);
|
||||
const MipsMCExpr *HiExpr = MipsMCExpr::create(
|
||||
MCSymbolRefExpr::VK_Mips_ABS_HI, Symbol, getContext());
|
||||
const MipsMCExpr *LoExpr = MipsMCExpr::create(
|
||||
MCSymbolRefExpr::VK_Mips_ABS_LO, Symbol, getContext());
|
||||
|
||||
bool UseSrcReg = SrcReg != Mips::NoRegister;
|
||||
|
||||
|
@ -2360,10 +2357,10 @@ bool MipsAsmParser::loadAndAddSymbolAddress(
|
|||
if (!ATReg)
|
||||
return true;
|
||||
|
||||
const MCSymbolRefExpr *HighestExpr = MCSymbolRefExpr::create(
|
||||
&Symbol->getSymbol(), MCSymbolRefExpr::VK_Mips_HIGHEST, getContext());
|
||||
const MCSymbolRefExpr *HigherExpr = MCSymbolRefExpr::create(
|
||||
&Symbol->getSymbol(), MCSymbolRefExpr::VK_Mips_HIGHER, getContext());
|
||||
const MipsMCExpr *HighestExpr = MipsMCExpr::create(
|
||||
MCSymbolRefExpr::VK_Mips_HIGHEST, Symbol, getContext());
|
||||
const MipsMCExpr *HigherExpr = MipsMCExpr::create(
|
||||
MCSymbolRefExpr::VK_Mips_HIGHER, Symbol, getContext());
|
||||
|
||||
if (UseSrcReg && (DstReg == SrcReg)) {
|
||||
// If $rs is the same as $rd:
|
||||
|
|
|
@ -634,51 +634,74 @@ symbol: # CHECK-LABEL: symbol:
|
|||
.extern extern_sym
|
||||
.option pic0
|
||||
dla $5, extern_sym # CHECK: lui $5, %highest(extern_sym) # encoding: [0x3c,0x05,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: extern_sym@HIGHEST, kind: fixup_Mips_HIGHEST
|
||||
# CHECK: # fixup A - offset: 0, value: %highest(extern_sym), kind: fixup_Mips_HIGHEST
|
||||
# CHECK: lui $1, %hi(extern_sym) # encoding: [0x3c,0x01,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: extern_sym@ABS_HI, kind: fixup_Mips_HI16
|
||||
# CHECK: # fixup A - offset: 0, value: %hi(extern_sym), kind: fixup_Mips_HI16
|
||||
# CHECK: daddiu $5, $5, %higher(extern_sym) # encoding: [0x64,0xa5,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: extern_sym@HIGHER, kind: fixup_Mips_HIGHER
|
||||
# CHECK: # fixup A - offset: 0, value: %higher(extern_sym), kind: fixup_Mips_HIGHER
|
||||
# CHECK: daddiu $1, $1, %lo(extern_sym) # encoding: [0x64,0x21,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: extern_sym@ABS_LO, kind: fixup_Mips_LO16
|
||||
# CHECK: # fixup A - offset: 0, value: %lo(extern_sym), kind: fixup_Mips_LO16
|
||||
# CHECK: dsll32 $5, $5, 0 # encoding: [0x00,0x05,0x28,0x3c]
|
||||
# CHECK: daddu $5, $5, $1 # encoding: [0x00,0xa1,0x28,0x2d]
|
||||
|
||||
# FIXME: Simple symbol expressions crash the assembler.
|
||||
#dla $5, extern_sym+8 # TODO: lui $5, %highest(extern_sym) # encoding: [0x3c,0x05,A,A]
|
||||
# TODO: # fixup A - offset: 0, value: extern_sym@HIGHEST, kind: fixup_Mips_HIGHEST
|
||||
# TODO: lui $1, %hi(extern_sym) # encoding: [0x3c,0x01,A,A]
|
||||
# TODO: # fixup A - offset: 0, value: extern_sym@ABS_HI, kind: fixup_Mips_HI16
|
||||
# TODO: daddiu $5, $5, %higher(extern_sym) # encoding: [0x64,0xa5,A,A]
|
||||
# TODO: # fixup A - offset: 0, value: extern_sym@HIGHER, kind: fixup_Mips_HIGHER
|
||||
# TODO: daddiu $1, $1, %lo(extern_sym) # encoding: [0x64,0x21,A,A]
|
||||
# TODO: # fixup A - offset: 0, value: extern_sym@ABS_LO, kind: fixup_Mips_LO16
|
||||
# TODO: dsll32 $5, $5, 0 # encoding: [0x00,0x05,0x28,0x3c]
|
||||
# TODO: daddu $5, $5, $1 # encoding: [0x00,0xa1,0x28,0x2d]
|
||||
|
||||
dla $5, extern_sym($8) # CHECK: lui $5, %highest(extern_sym) # encoding: [0x3c,0x05,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: extern_sym@HIGHEST, kind: fixup_Mips_HIGHEST
|
||||
# CHECK: # fixup A - offset: 0, value: %highest(extern_sym), kind: fixup_Mips_HIGHEST
|
||||
# CHECK: lui $1, %hi(extern_sym) # encoding: [0x3c,0x01,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: extern_sym@ABS_HI, kind: fixup_Mips_HI16
|
||||
# CHECK: # fixup A - offset: 0, value: %hi(extern_sym), kind: fixup_Mips_HI16
|
||||
# CHECK: daddiu $5, $5, %higher(extern_sym) # encoding: [0x64,0xa5,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: extern_sym@HIGHER, kind: fixup_Mips_HIGHER
|
||||
# CHECK: # fixup A - offset: 0, value: %higher(extern_sym), kind: fixup_Mips_HIGHER
|
||||
# CHECK: daddiu $1, $1, %lo(extern_sym) # encoding: [0x64,0x21,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: extern_sym@ABS_LO, kind: fixup_Mips_LO16
|
||||
# CHECK: # fixup A - offset: 0, value: %lo(extern_sym), kind: fixup_Mips_LO16
|
||||
# CHECK: dsll32 $5, $5, 0 # encoding: [0x00,0x05,0x28,0x3c]
|
||||
# CHECK: daddu $5, $5, $1 # encoding: [0x00,0xa1,0x28,0x2d]
|
||||
# CHECK: daddu $5, $5, $8 # encoding: [0x00,0xa8,0x28,0x2d]
|
||||
|
||||
dla $5, extern_sym($5) # CHECK: lui $1, %highest(extern_sym) # encoding: [0x3c,0x01,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: extern_sym@HIGHEST, kind: fixup_Mips_HIGHEST
|
||||
# CHECK: # fixup A - offset: 0, value: %highest(extern_sym), kind: fixup_Mips_HIGHEST
|
||||
# CHECK: daddiu $1, $1, %higher(extern_sym) # encoding: [0x64,0x21,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: extern_sym@HIGHER, kind: fixup_Mips_HIGHER
|
||||
# CHECK: # fixup A - offset: 0, value: %higher(extern_sym), kind: fixup_Mips_HIGHER
|
||||
# CHECK: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38]
|
||||
# CHECK: daddiu $1, $1, %hi(extern_sym) # encoding: [0x64,0x21,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: extern_sym@ABS_HI, kind: fixup_Mips_HI16
|
||||
# CHECK: # fixup A - offset: 0, value: %hi(extern_sym), kind: fixup_Mips_HI16
|
||||
# CHECK: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38]
|
||||
# CHECK: daddiu $1, $1, %lo(extern_sym) # encoding: [0x64,0x21,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: extern_sym@ABS_LO, kind: fixup_Mips_LO16
|
||||
# CHECK: # fixup A - offset: 0, value: %lo(extern_sym), kind: fixup_Mips_LO16
|
||||
# CHECK: daddu $5, $1, $5 # encoding: [0x00,0x25,0x28,0x2d]
|
||||
|
||||
dla $5, extern_sym+8 # CHECK: lui $5, %highest(extern_sym+8) # encoding: [0x3c,0x05,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %highest(extern_sym+8), kind: fixup_Mips_HIGHEST
|
||||
# CHECK: lui $1, %hi(extern_sym+8) # encoding: [0x3c,0x01,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %hi(extern_sym+8), kind: fixup_Mips_HI16
|
||||
# CHECK: daddiu $5, $5, %higher(extern_sym+8) # encoding: [0x64,0xa5,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %higher(extern_sym+8), kind: fixup_Mips_HIGHER
|
||||
# CHECK: daddiu $1, $1, %lo(extern_sym+8) # encoding: [0x64,0x21,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %lo(extern_sym+8), kind: fixup_Mips_LO16
|
||||
# CHECK: dsll32 $5, $5, 0 # encoding: [0x00,0x05,0x28,0x3c]
|
||||
# CHECK: daddu $5, $5, $1 # encoding: [0x00,0xa1,0x28,0x2d]
|
||||
|
||||
dla $5, extern_sym+8($8) # CHECK: lui $5, %highest(extern_sym+8) # encoding: [0x3c,0x05,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %highest(extern_sym+8), kind: fixup_Mips_HIGHEST
|
||||
# CHECK: lui $1, %hi(extern_sym+8) # encoding: [0x3c,0x01,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %hi(extern_sym+8), kind: fixup_Mips_HI16
|
||||
# CHECK: daddiu $5, $5, %higher(extern_sym+8) # encoding: [0x64,0xa5,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %higher(extern_sym+8), kind: fixup_Mips_HIGHER
|
||||
# CHECK: daddiu $1, $1, %lo(extern_sym+8) # encoding: [0x64,0x21,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %lo(extern_sym+8), kind: fixup_Mips_LO16
|
||||
# CHECK: dsll32 $5, $5, 0 # encoding: [0x00,0x05,0x28,0x3c]
|
||||
# CHECK: daddu $5, $5, $1 # encoding: [0x00,0xa1,0x28,0x2d]
|
||||
# CHECK: daddu $5, $5, $8 # encoding: [0x00,0xa8,0x28,0x2d]
|
||||
|
||||
dla $5, extern_sym+8($5) # CHECK: lui $1, %highest(extern_sym+8) # encoding: [0x3c,0x01,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %highest(extern_sym+8), kind: fixup_Mips_HIGHEST
|
||||
# CHECK: daddiu $1, $1, %higher(extern_sym+8) # encoding: [0x64,0x21,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %higher(extern_sym+8), kind: fixup_Mips_HIGHER
|
||||
# CHECK: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38]
|
||||
# CHECK: daddiu $1, $1, %hi(extern_sym+8) # encoding: [0x64,0x21,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %hi(extern_sym+8), kind: fixup_Mips_HI16
|
||||
# CHECK: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38]
|
||||
# CHECK: daddiu $1, $1, %lo(extern_sym+8) # encoding: [0x64,0x21,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %lo(extern_sym+8), kind: fixup_Mips_LO16
|
||||
# CHECK: daddu $5, $1, $5 # encoding: [0x00,0x25,0x28,0x2d]
|
||||
|
||||
.option pic2
|
||||
#dla $5, symbol
|
||||
|
|
|
@ -245,21 +245,35 @@ la $6, 0x80008000($6) # CHECK: lui $1, 32768 # encoding: [0x3c,0x01,0x80,0x0
|
|||
# CHECK: addu $6, $1, $6 # encoding: [0x00,0x26,0x30,0x21]
|
||||
|
||||
la $5, symbol # CHECK: lui $5, %hi(symbol) # encoding: [0x3c,0x05,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
|
||||
# CHECK: # fixup A - offset: 0, value: %hi(symbol), kind: fixup_Mips_HI16
|
||||
# CHECK: addiu $5, $5, %lo(symbol) # encoding: [0x24,0xa5,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
|
||||
# CHECK: # fixup A - offset: 0, value: %lo(symbol), kind: fixup_Mips_LO16
|
||||
la $5, symbol($6) # CHECK: lui $5, %hi(symbol) # encoding: [0x3c,0x05,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
|
||||
# CHECK: # fixup A - offset: 0, value: %hi(symbol), kind: fixup_Mips_HI16
|
||||
# CHECK: addiu $5, $5, %lo(symbol) # encoding: [0x24,0xa5,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
|
||||
# CHECK: # fixup A - offset: 0, value: %lo(symbol), kind: fixup_Mips_LO16
|
||||
# CHECK: addu $5, $5, $6 # encoding: [0x00,0xa6,0x28,0x21]
|
||||
la $6, symbol($6) # CHECK: lui $1, %hi(symbol) # encoding: [0x3c,0x01,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
|
||||
# CHECK: # fixup A - offset: 0, value: %hi(symbol), kind: fixup_Mips_HI16
|
||||
# CHECK: addiu $1, $1, %lo(symbol) # encoding: [0x24,0x21,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
|
||||
# CHECK: # fixup A - offset: 0, value: %lo(symbol), kind: fixup_Mips_LO16
|
||||
# CHECK: addu $6, $1, $6 # encoding: [0x00,0x26,0x30,0x21]
|
||||
la $5, 1f # CHECK: lui $5, %hi($tmp0) # encoding: [0x3c,0x05,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: ($tmp0)@ABS_HI, kind: fixup_Mips_HI16
|
||||
# CHECK: addiu $5, $5, %lo($tmp0) # encoding: [0x24,0xa5,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: ($tmp0)@ABS_LO, kind: fixup_Mips_LO16
|
||||
la $5, symbol+8 # CHECK: lui $5, %hi(symbol+8) # encoding: [0x3c,0x05,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %hi(symbol+8), kind: fixup_Mips_HI16
|
||||
# CHECK: addiu $5, $5, %lo(symbol+8) # encoding: [0x24,0xa5,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %lo(symbol+8), kind: fixup_Mips_LO16
|
||||
la $5, symbol+8($6) # CHECK: lui $5, %hi(symbol+8) # encoding: [0x3c,0x05,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %hi(symbol+8), kind: fixup_Mips_HI16
|
||||
# CHECK: addiu $5, $5, %lo(symbol+8) # encoding: [0x24,0xa5,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %lo(symbol+8), kind: fixup_Mips_LO16
|
||||
# CHECK: addu $5, $5, $6 # encoding: [0x00,0xa6,0x28,0x21]
|
||||
la $6, symbol+8($6) # CHECK: lui $1, %hi(symbol+8) # encoding: [0x3c,0x01,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %hi(symbol+8), kind: fixup_Mips_HI16
|
||||
# CHECK: addiu $1, $1, %lo(symbol+8) # encoding: [0x24,0x21,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %lo(symbol+8), kind: fixup_Mips_LO16
|
||||
# CHECK: addu $6, $1, $6 # encoding: [0x00,0x26,0x30,0x21]
|
||||
la $5, 1f # CHECK: lui $5, %hi(($tmp0)) # encoding: [0x3c,0x05,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %hi(($tmp0)), kind: fixup_Mips_HI16
|
||||
# CHECK: addiu $5, $5, %lo(($tmp0)) # encoding: [0x24,0xa5,A,A]
|
||||
# CHECK: # fixup A - offset: 0, value: %lo(($tmp0)), kind: fixup_Mips_LO16
|
||||
1:
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
# Load address, done by MipsAsmParser::expandLoadAddressReg()
|
||||
# and MipsAsmParser::expandLoadAddressImm():
|
||||
la $8, 1f
|
||||
# CHECK-LE: lui $8, %hi($tmp0) # encoding: [A,A,0x08,0x3c]
|
||||
# CHECK-LE: # fixup A - offset: 0, value: ($tmp0)@ABS_HI, kind: fixup_Mips_HI16
|
||||
# CHECK-LE: addiu $8, $8, %lo($tmp0) # encoding: [A,A,0x08,0x25]
|
||||
# CHECK-LE: # fixup A - offset: 0, value: ($tmp0)@ABS_LO, kind: fixup_Mips_LO16
|
||||
# CHECK-LE: lui $8, %hi(($tmp0)) # encoding: [A,A,0x08,0x3c]
|
||||
# CHECK-LE: # fixup A - offset: 0, value: %hi(($tmp0)), kind: fixup_Mips_HI16
|
||||
# CHECK-LE: addiu $8, $8, %lo(($tmp0)) # encoding: [A,A,0x08,0x25]
|
||||
# CHECK-LE: # fixup A - offset: 0, value: %lo(($tmp0)), kind: fixup_Mips_LO16
|
||||
|
||||
# LW/SW and LDC1/SDC1 of symbol address, done by MipsAsmParser::expandMemInst():
|
||||
.set noat
|
||||
|
|
Loading…
Reference in New Issue