[PATCH] D23110: [mips][ias] Fix all the hacks related to MIPS-specific unary operators (%hi/%lo/%gp_rel/etc.).

Daniel Sanders via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 3 02:28:12 PDT 2016


dsanders created this revision.
dsanders added a reviewer: sdardis.
dsanders added a subscriber: llvm-commits.
Herald added subscribers: sdardis, dsanders.

They are now lexed as a single token on targets where
MCAsmInfo::HasMipsExpressions is true and then parsed in a similar way to
the '~' operator as part of MCExpr::parseExpression.

As a result:
* expressions and immediates no longer have different parsing rules. The
  difference is now solely down to whether evaluateAsAbsolute() succeeds.
* %hi(%neg(%gp_rel(x))) are no longer parsed as a single operator and
  decomposed into the three MipsMCExpr nodes. They are parsed directly as
  three MipsMCExpr nodes.
  * parseMemOperand no longer needs to eat all the surrounding parenthesis
    to get at the outermost operator to make this work
* %hi(%neg(%gp_rel(x))) and %lo(%neg(%gp_rel(x))) are no longer the only
  3-in-1 relocs that parse for N64. They're still the only combinations that
  are permitted in relocatable expressions though. Fixing that should be a
  later patch.
* We no longer need to list all the tokens that can occur as the first token of
  an expression or immediate.

test/MC/Mips/expr1.s:
    This change also prevents the incorrect lowering of %lo(2*4)+foo to
    %lo(8+foo) which is not an equivalent expression (the difference is
    whether foo is truncated to 16-bit or not) and the test has been
    updated to account for the macro expansion the correct expression requires.

https://reviews.llvm.org/D23110

Files:
  include/llvm/MC/MCAsmInfo.h
  include/llvm/MC/MCParser/MCAsmLexer.h
  include/llvm/MC/MCParser/MCTargetAsmParser.h
  lib/MC/MCParser/AsmLexer.cpp
  lib/MC/MCParser/AsmParser.cpp
  lib/Target/Mips/AsmParser/MipsAsmParser.cpp
  lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp
  lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
  lib/Target/Mips/MCTargetDesc/MipsFixupKinds.h
  lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
  lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
  test/MC/Mips/expr1.s
  test/MC/Mips/relocation.s
  tools/llvm-mc/llvm-mc.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23110.66630.patch
Type: text/x-patch
Size: 30249 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160803/e136aa46/attachment-0001.bin>


More information about the llvm-commits mailing list