[llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp
Chris Lattner
clattner at apple.com
Thu Apr 26 14:20:09 PDT 2007
> Fix PR1339: http://llvm.org/PR1339 and CodeGen/X86/dollar-name.ll
Nice, thanks Dan!
-Chris
>
> ---
> Diffs of the changes: (+32 -3)
>
> X86ATTAsmPrinter.cpp | 35 ++++++++++++++++++++++++++++++++---
> 1 files changed, 32 insertions(+), 3 deletions(-)
>
>
> Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp
> diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.102 llvm/lib/
> Target/X86/X86ATTAsmPrinter.cpp:1.103
> --- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.102 Sun Apr 22
> 17:50:52 2007
> +++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Thu Apr 26 16:07:05 2007
> @@ -272,16 +272,24 @@
> case MachineOperand::MO_GlobalAddress: {
> bool isCallOp = Modifier && !strcmp(Modifier, "call");
> bool isMemOp = Modifier && !strcmp(Modifier, "mem");
> + bool needCloseParen = false;
>
> GlobalValue *GV = MO.getGlobal();
> GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
> bool isThreadLocal = GVar && GVar->isThreadLocal();
>
> - if (!isMemOp && !isCallOp) O << '$';
> -
> std::string Name = Mang->getValueName(GV);
> X86SharedAsmPrinter::decorateName(Name, GV);
>
> + if (!isMemOp && !isCallOp)
> + O << '$';
> + else if (Name[0] == '$') {
> + // The name begins with a dollar-sign. In order to avoid
> having it look
> + // like an integer immediate to the assembler, enclose it in
> parens.
> + O << '(';
> + needCloseParen = true;
> + }
> +
> if (printStub(TM, Subtarget)) {
> // Link-once, External, or Weakly-linked global variables need
> // non-lazily-resolved stubs
> @@ -352,6 +360,12 @@
> GV->hasLinkOnceLinkage()) &&
> TM.getRelocationModel() != Reloc::Static)
> O << "@GOTPCREL";
> +
> + if (needCloseParen) {
> + needCloseParen = false;
> + O << ')';
> + }
> +
> // Use rip when possible to reduce code size, except when
> // index or base register are also part of the address. e.g.
> // foo(%rip)(%rcx,%rax,4) is not legal
> @@ -359,10 +373,14 @@
> }
> }
>
> + if (needCloseParen)
> + O << ')';
> +
> return;
> }
> case MachineOperand::MO_ExternalSymbol: {
> bool isCallOp = Modifier && !strcmp(Modifier, "call");
> + bool needCloseParen = false;
> std::string Name(TAI->getGlobalPrefix());
> Name += MO.getSymbolName();
> if (isCallOp && printStub(TM, Subtarget)) {
> @@ -370,7 +388,15 @@
> O << TAI->getPrivateGlobalPrefix() << Name << "$stub";
> return;
> }
> - if (!isCallOp) O << '$';
> + if (!isCallOp)
> + O << '$';
> + else if (Name[0] == '$') {
> + // The name begins with a dollar-sign. In order to avoid
> having it look
> + // like an integer immediate to the assembler, enclose it in
> parens.
> + O << '(';
> + needCloseParen = true;
> + }
> +
> O << Name;
>
> if (printGOT(TM, Subtarget)) {
> @@ -391,6 +417,9 @@
> O << "@PLT";
> }
>
> + if (needCloseParen)
> + O << ')';
> +
> if (!isCallOp && Subtarget->isPICStyleRIPRel())
> O << "(%rip)";
>
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list