[llvm-commits] CVS: llvm/lib/Target/Sparc/EmitAssembly.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Oct 14 01:15:01 PDT 2002
Changes in directory llvm/lib/Target/Sparc:
EmitAssembly.cpp updated: 1.61 -> 1.62
---
Log message:
Allow emission of names that start with an underscore. This is needed to
interface with code that uses symbols in the ansi-c protected namespace. In
most cases this comes from system header files, such as stdio.h. In particular,
without this change, a reference to the __iob symbol is mangled into ll_iob,
which is not resolved by libc.
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/EmitAssembly.cpp
diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.61 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.62
--- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.61 Sat Oct 12 19:32:18 2002
+++ llvm/lib/Target/Sparc/EmitAssembly.cpp Mon Oct 14 01:14:18 2002
@@ -15,7 +15,6 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineCodeForBasicBlock.h"
#include "llvm/CodeGen/MachineCodeForMethod.h"
-#include "llvm/GlobalVariable.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
@@ -23,7 +22,6 @@
#include "llvm/Pass.h"
#include "llvm/Assembly/Writer.h"
#include "Support/StringExtras.h"
-#include <iostream>
using std::string;
namespace {
@@ -110,16 +108,15 @@
toAsm << "\n";
}
- static std::string getValidSymbolName(const string &S) {
+ static string getValidSymbolName(const string &S) {
string Result;
// Symbol names in Sparc assembly language have these rules:
// (a) Must match { letter | _ | . | $ } { letter | _ | . | $ | digit }*
// (b) A name beginning in "." is treated as a local name.
- // (c) Names beginning with "_" are reserved by ANSI C and shd not be used.
//
- if (S[0] == '_' || isdigit(S[0]))
- Result += "ll";
+ if (isdigit(S[0]))
+ Result = "ll";
for (unsigned i = 0; i < S.size(); ++i)
{
@@ -186,10 +183,9 @@
// ConstantExprToString() - Convert a ConstantExpr to an asm expression
// and return this as a string.
- std::string ConstantExprToString(const ConstantExpr* CE,
- const TargetMachine& target) {
- std::string S;
-
+ string ConstantExprToString(const ConstantExpr* CE,
+ const TargetMachine& target) {
+ string S;
switch(CE->getOpcode()) {
case Instruction::GetElementPtr:
{ // generate a symbolic expression for the byte address
@@ -225,13 +221,13 @@
// valToExprString - Helper function for ConstantExprToString().
// Appends result to argument string S.
//
- std::string valToExprString(const Value* V, const TargetMachine& target) {
- std::string S;
+ string valToExprString(const Value* V, const TargetMachine& target) {
+ string S;
bool failed = false;
if (const Constant* CV = dyn_cast<Constant>(V)) { // symbolic or known
if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV))
- S += std::string(CB == ConstantBool::True ? "1" : "0");
+ S += string(CB == ConstantBool::True ? "1" : "0");
else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV))
S += itostr(CI->getValue());
else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV))
@@ -547,7 +543,7 @@
void PrintZeroBytesToPad (int numBytes);
void printSingleConstantValue (const Constant* CV);
void printConstantValueOnly (const Constant* CV, int numPadBytes = 0);
- void printConstant (const Constant* CV, std::string valID = "");
+ void printConstant (const Constant* CV, string valID = "");
static void FoldConstants (const Module &M,
hash_set<const Constant*> &moduleConstants);
More information about the llvm-commits
mailing list