From: Chris Lattner Date: Fri, 28 Sep 2001 15:07:24 +0000 (+0000) Subject: * Properly escape function names X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c56d779501901e22103a1236768cb97fd9b5c9b0;p=oota-llvm.git * Properly escape function names * Ignore %xcc argument on conditional branches git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@663 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index 6987ade3943..ae8926071e2 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp @@ -68,6 +68,23 @@ private : Out << "\"\n"; } + string getEscapedString(const string &S) { + string Result; + + for (unsigned i = 0; i < S.size(); ++i) { + char C = S[i]; + if ((C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') || + (C >= '0' && C <= '9')) { + Result += C; + } else { + Result += '$'; + Result += char('0' + ((unsigned char)C >> 4)); + Result += char('0' + (C & 0xF)); + } + } + return Result; + } + // getID - Return a valid identifier for the specified value. Base it on // the name of the identifier if possible, use a numbered value based on // prefix otherwise. FPrefix is always prepended to the output identifier. @@ -75,7 +92,7 @@ private : string getID(const Value *V, const char *Prefix, const char *FPrefix = 0) { string FP(FPrefix ? FPrefix : ""); // "Forced prefix" if (V->hasName()) { - return FP + V->getName(); // TODO: Escape name if needed + return FP + getEscapedString(V->getName()); } else { assert(Table.getValSlot(V) != -1 && "Value not in value table!"); return FP + string(Prefix) + itostr(Table.getValSlot(V)); @@ -91,7 +108,10 @@ private : unsigned getOperandMask(unsigned Opcode) { switch (Opcode) { case SUBcc: return 1 << 3; // Remove CC argument - case BA: return 1 << 0; // Remove Arg #0, which is always null + case BA: case BRZ: // Remove Arg #0, which is always null or xcc + case BRLEZ: case BRLZ: + case BRNZ: case BRGZ: + case BRGEZ: return 1 << 0; default: return 0; // By default, don't hack operands... } } @@ -176,7 +196,7 @@ void SparcAsmPrinter::emitMethod(const Method *M) { Out << "!****** Outputing Method: " << MethName << " ******\n"; enterSection(Text); Out << "\t.align 4\n\t.global\t" << MethName << "\n"; - Out << "\t.type\t" << MethName << ",#function\n"; + //Out << "\t.type\t" << MethName << ",#function\n"; Out << MethName << ":\n"; // Output code for all of the basic blocks in the method...