Make sure to put an _ prefix on all identifiers!

Also, add some (currently disabled) code to print float's as 32-bits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15846 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-08-17 02:29:00 +00:00
parent ed1ff01639
commit 505e783d8c
2 changed files with 58 additions and 32 deletions

View File

@ -46,7 +46,9 @@ namespace {
std::set<std::string> Strings; std::set<std::string> Strings;
PowerPCAsmPrinter(std::ostream &O, TargetMachine &TM) PowerPCAsmPrinter(std::ostream &O, TargetMachine &TM)
: AsmPrinter(O, TM), LabelNumber(0) {} : AsmPrinter(O, TM), LabelNumber(0) {
UsesUnderscorePrefix = 1;
}
/// Unique incrementer for label values for referencing Global values. /// Unique incrementer for label values for referencing Global values.
/// ///
@ -193,21 +195,32 @@ void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
// FP Constants are printed as integer constants to avoid losing // FP Constants are printed as integer constants to avoid losing
// precision... // precision...
double Val = CFP->getValue(); double Val = CFP->getValue();
union DU { // Abide by C TBAA rules if (1 || CFP->getType() == Type::DoubleTy) {
double FVal; union DU { // Abide by C TBAA rules
uint64_t UVal; double FVal;
struct { uint64_t UVal;
uint32_t MSWord; struct {
uint32_t LSWord; uint32_t MSWord;
} T; uint32_t LSWord;
} U; } T;
U.FVal = Val; } U;
U.FVal = Val;
O << ".long\t" << U.T.MSWord << "\t; double most significant word "
<< Val << "\n"; O << ".long\t" << U.T.MSWord << "\t; double most significant word "
O << ".long\t" << U.T.LSWord << "\t; double least significant word " << Val << "\n";
<< Val << "\n"; O << ".long\t" << U.T.LSWord << "\t; double least significant word "
return; << Val << "\n";
return;
} else {
union FU { // Abide by C TBAA rules
float FVal;
int32_t UVal;
} U;
U.FVal = Val;
O << ".long\t" << U.UVal << "\t; float " << Val << "\n";
return;
}
} else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) { } else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) {
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) { if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
union DU { // Abide by C TBAA rules union DU { // Abide by C TBAA rules

View File

@ -46,7 +46,9 @@ namespace {
std::set<std::string> Strings; std::set<std::string> Strings;
PowerPCAsmPrinter(std::ostream &O, TargetMachine &TM) PowerPCAsmPrinter(std::ostream &O, TargetMachine &TM)
: AsmPrinter(O, TM), LabelNumber(0) {} : AsmPrinter(O, TM), LabelNumber(0) {
UsesUnderscorePrefix = 1;
}
/// Unique incrementer for label values for referencing Global values. /// Unique incrementer for label values for referencing Global values.
/// ///
@ -193,21 +195,32 @@ void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
// FP Constants are printed as integer constants to avoid losing // FP Constants are printed as integer constants to avoid losing
// precision... // precision...
double Val = CFP->getValue(); double Val = CFP->getValue();
union DU { // Abide by C TBAA rules if (1 || CFP->getType() == Type::DoubleTy) {
double FVal; union DU { // Abide by C TBAA rules
uint64_t UVal; double FVal;
struct { uint64_t UVal;
uint32_t MSWord; struct {
uint32_t LSWord; uint32_t MSWord;
} T; uint32_t LSWord;
} U; } T;
U.FVal = Val; } U;
U.FVal = Val;
O << ".long\t" << U.T.MSWord << "\t; double most significant word "
<< Val << "\n"; O << ".long\t" << U.T.MSWord << "\t; double most significant word "
O << ".long\t" << U.T.LSWord << "\t; double least significant word " << Val << "\n";
<< Val << "\n"; O << ".long\t" << U.T.LSWord << "\t; double least significant word "
return; << Val << "\n";
return;
} else {
union FU { // Abide by C TBAA rules
float FVal;
int32_t UVal;
} U;
U.FVal = Val;
O << ".long\t" << U.UVal << "\t; float " << Val << "\n";
return;
}
} else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) { } else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) {
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) { if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
union DU { // Abide by C TBAA rules union DU { // Abide by C TBAA rules