From lattner at cs.uiuc.edu Mon Nov 21 00:41:20 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 00:41:20 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h Message-ID: <200511210641.AAA03175@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: AsmPrinter.h updated: 1.15 -> 1.16 --- Log message: Add a new option. --- Diffs of the changes: (+6 -0) AsmPrinter.h | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/include/llvm/CodeGen/AsmPrinter.h diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.15 llvm/include/llvm/CodeGen/AsmPrinter.h:1.16 --- llvm/include/llvm/CodeGen/AsmPrinter.h:1.15 Mon Nov 14 12:59:42 2005 +++ llvm/include/llvm/CodeGen/AsmPrinter.h Mon Nov 21 00:41:08 2005 @@ -54,6 +54,11 @@ /// onto all global symbols. This is often used for "_" or ".". const char *GlobalPrefix; // Defaults to "" + /// PrivateGlobalPrefix - This prefix is used for globals like constant + /// pool entries that are completely private to the .o file and should not + /// have names in the .o file. This is often "." or "L". + const char *PrivateGlobalPrefix; // Defaults to "." + /// GlobalVarAddrPrefix/Suffix - If these are nonempty, these strings /// will enclose any GlobalVariable (that isn't a function) /// @@ -107,6 +112,7 @@ : O(o), TM(tm), CommentString("#"), GlobalPrefix(""), + PrivateGlobalPrefix("."), GlobalVarAddrPrefix(""), GlobalVarAddrSuffix(""), FunctionAddrPrefix(""), From lattner at cs.uiuc.edu Mon Nov 21 00:46:33 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 00:46:33 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86AsmPrinter.cpp X86IntelAsmPrinter.cpp Message-ID: <200511210646.AAA03302@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ATTAsmPrinter.cpp updated: 1.8 -> 1.9 X86AsmPrinter.cpp updated: 1.145 -> 1.146 X86IntelAsmPrinter.cpp updated: 1.4 -> 1.5 --- Log message: Naturally align doubles in the constant pool, set PrivateGlobalPrefix on darwin, use it when printing the constant pool indices so the labels are appropriately private, emit cp entries to .const instead of .data on darwin and only emit a single .section for the constant pool, not one for each entry. --- Diffs of the changes: (+17 -8) X86ATTAsmPrinter.cpp | 2 +- X86AsmPrinter.cpp | 21 +++++++++++++++------ X86IntelAsmPrinter.cpp | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.8 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.9 --- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.8 Wed Jul 27 01:12:34 2005 +++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Mon Nov 21 00:46:22 2005 @@ -174,7 +174,7 @@ O << "]"; return; } else if (BaseReg.isConstantPoolIndex()) { - O << ".CPI" << CurrentFnName << "_" + O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << BaseReg.getConstantPoolIndex(); if (DispSpec.getImmedValue()) O << "+" << DispSpec.getImmedValue(); Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.145 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.146 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.145 Wed Jul 27 01:12:34 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Mon Nov 21 00:46:22 2005 @@ -18,6 +18,7 @@ #include "X86IntelAsmPrinter.h" #include "X86.h" #include "llvm/Module.h" +#include "llvm/Type.h" #include "llvm/Assembly/Writer.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/Support/Mangler.h" @@ -66,6 +67,7 @@ AlignmentIsInBytes = false; Data64bitsDirective = 0; // we can't emit a 64-bit unit ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. + PrivateGlobalPrefix = "L"; // Marker for constant pool idxs } return AsmPrinter::doInitialization(M); @@ -82,14 +84,21 @@ if (CP.empty()) return; + if (forDarwin) { + O << "\t.const\n"; + } else { + O << "\t.section .rodata\n"; + } + for (unsigned i = 0, e = CP.size(); i != e; ++i) { - if (forDarwin) - O << "\t.data\n"; + // FIXME: force doubles to be naturally aligned. We should handle this + // more correctly in the future. + if (CP[i]->getType() == Type::DoubleTy) + emitAlignment(3); else - O << "\t.section .rodata\n"; - emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); - O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString - << *CP[i] << "\n"; + emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); + O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i + << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n"; emitGlobalConstant(CP[i]); } } Index: llvm/lib/Target/X86/X86IntelAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.4 llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.5 --- llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.4 Thu Jul 14 17:52:25 2005 +++ llvm/lib/Target/X86/X86IntelAsmPrinter.cpp Mon Nov 21 00:46:22 2005 @@ -141,7 +141,7 @@ O << "]"; return; } else if (BaseReg.isConstantPoolIndex()) { - O << "[.CPI" << CurrentFnName << "_" + O << "[" << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << BaseReg.getConstantPoolIndex(); if (IndexReg.getReg()) { From lattner at cs.uiuc.edu Mon Nov 21 00:48:10 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 00:48:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Message-ID: <200511210648.AAA03370@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCAsmPrinter.cpp updated: 1.113 -> 1.114 --- Log message: set PrivateGlobalPrefix on darwin, use it when printing out CP references --- Diffs of the changes: (+9 -7) PPCAsmPrinter.cpp | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.113 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.114 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.113 Thu Nov 17 13:40:30 2005 +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Mon Nov 21 00:47:58 2005 @@ -230,6 +230,7 @@ : PPCAsmPrinter(O, TM) { CommentString = ";"; GlobalPrefix = "_"; + PrivateGlobalPrefix = "L"; // Marker for constant pool idxs ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. Data64bitsDirective = 0; // we can't emit a 64-bit unit AlignmentIsInBytes = false; // Alignment is by power of 2. @@ -326,7 +327,8 @@ } case MachineOperand::MO_ConstantPoolIndex: - O << "LCPI" << FunctionNumber << '_' << MO.getConstantPoolIndex(); + O << PrivateGlobalPrefix << "CPI" << FunctionNumber + << '_' << MO.getConstantPoolIndex(); return; case MachineOperand::MO_ExternalSymbol: @@ -447,16 +449,16 @@ if (CP.empty()) return; + SwitchSection(".const", 0); for (unsigned i = 0, e = CP.size(); i != e; ++i) { - SwitchSection(".const", 0); // FIXME: force doubles to be naturally aligned. We should handle this // more correctly in the future. - if (Type::DoubleTy == CP[i]->getType()) + if (CP[i]->getType() == Type::DoubleTy) emitAlignment(3); else emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); - O << "LCPI" << FunctionNumber << '_' << i << ":\t\t\t\t\t" << CommentString - << *CP[i] << '\n'; + O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i + << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n'; emitGlobalConstant(CP[i]); } } @@ -664,8 +666,8 @@ SwitchSection(".const", 0); O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType()) << "\n"; - O << "LCPI" << FunctionNumber << '_' << i << ":\t\t\t\t\t;" - << *CP[i] << '\n'; + O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i + << ":\t\t\t\t\t;" << *CP[i] << '\n'; emitGlobalConstant(CP[i]); } } From lattner at cs.uiuc.edu Mon Nov 21 00:52:04 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 00:52:04 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64AsmPrinter.cpp Message-ID: <200511210652.AAA03442@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64AsmPrinter.cpp updated: 1.13 -> 1.14 --- Log message: Start using PrivateGlobalPrefix correctly --- Diffs of the changes: (+3 -3) IA64AsmPrinter.cpp | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.13 llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.14 --- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.13 Fri Oct 28 12:46:36 2005 +++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Mon Nov 21 00:51:52 2005 @@ -88,8 +88,8 @@ // FIXME: would be nice to have rodata (no 'w') when appropriate? for (unsigned i = 0, e = CP.size(); i != e; ++i) { emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); - O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString - << *CP[i] << "\n"; + O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i + << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n"; emitGlobalConstant(CP[i]); } } @@ -357,7 +357,7 @@ return; case MachineOperand::MO_ConstantPoolIndex: { - O << "@gprel(.CPI" << CurrentFnName << "_" + O << "@gprel(" << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << MO.getConstantPoolIndex() << ")"; return; } From lattner at cs.uiuc.edu Mon Nov 21 00:52:04 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 00:52:04 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Message-ID: <200511210652.AAA03446@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaAsmPrinter.cpp updated: 1.20 -> 1.21 --- Log message: Start using PrivateGlobalPrefix correctly --- Diffs of the changes: (+5 -3) AlphaAsmPrinter.cpp | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) Index: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp diff -u llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.20 llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.21 --- llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.20 Thu Sep 29 17:54:56 2005 +++ llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Mon Nov 21 00:51:52 2005 @@ -43,6 +43,7 @@ : AsmPrinter(o, tm), LabelNumber(0) { AlignmentIsInBytes = false; + PrivateGlobalPrefix = "$"; } /// We name each basic block in a Function with a unique number, so @@ -131,7 +132,8 @@ } case MachineOperand::MO_ConstantPoolIndex: - O << "$CPI" << CurrentFnName << "_" << MO.getConstantPoolIndex(); + O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" + << MO.getConstantPoolIndex(); return; case MachineOperand::MO_ExternalSymbol: @@ -222,8 +224,8 @@ for (unsigned i = 0, e = CP.size(); i != e; ++i) { // SwitchSection(O, "section .rodata, \"dr\""); emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); - O << "$CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString - << *CP[i] << "\n"; + O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i + << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n"; emitGlobalConstant(CP[i]); } } From lattner at cs.uiuc.edu Mon Nov 21 00:55:39 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 00:55:39 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64AsmPrinter.cpp Message-ID: <200511210655.AAA03502@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64AsmPrinter.cpp updated: 1.14 -> 1.15 --- Log message: Rename SwitchSection -> switchSection to avoid conflicting with a future change. --- Diffs of the changes: (+6 -6) IA64AsmPrinter.cpp | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.14 llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.15 --- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.14 Mon Nov 21 00:51:52 2005 +++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Mon Nov 21 00:55:27 2005 @@ -61,10 +61,10 @@ MI->getOperand(Op+3).isGlobalAddress()); } -// SwitchSection - Switch to the specified section of the executable if we are +// switchSection - Switch to the specified section of the executable if we are // not already in it! // -static void SwitchSection(std::ostream &OS, std::string &CurSection, +static void switchSection(std::ostream &OS, std::string &CurSection, const char *NewSection) { if (CurSection != NewSection) { CurSection = NewSection; @@ -111,7 +111,7 @@ if (C->isNullValue() && (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || I->hasWeakLinkage() /* FIXME: Verify correct */)) { - SwitchSection(O, CurSection, ".data"); + switchSection(O, CurSection, ".data"); if (I->hasInternalLinkage()) { O << "\t.lcomm " << name << "," << TD.getTypeSize(C->getType()) << "," << (1 << Align); @@ -129,7 +129,7 @@ case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. // Nonnull linkonce -> weak O << "\t.weak " << name << "\n"; - SwitchSection(O, CurSection, ""); + switchSection(O, CurSection, ""); O << "\t.section\t.llvm.linkonce.d." << name << ", \"aw\", \"progbits\"\n"; break; @@ -142,9 +142,9 @@ // FALL THROUGH case GlobalValue::InternalLinkage: if (C->isNullValue()) - SwitchSection(O, CurSection, ".bss"); + switchSection(O, CurSection, ".bss"); else - SwitchSection(O, CurSection, ".data"); + switchSection(O, CurSection, ".data"); break; case GlobalValue::GhostLinkage: std::cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n"; From lattner at cs.uiuc.edu Mon Nov 21 00:55:40 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 00:55:40 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86AsmPrinter.cpp X86AsmPrinter.h Message-ID: <200511210655.AAA03508@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86AsmPrinter.cpp updated: 1.146 -> 1.147 X86AsmPrinter.h updated: 1.2 -> 1.3 --- Log message: Rename SwitchSection -> switchSection to avoid conflicting with a future change. --- Diffs of the changes: (+6 -6) X86AsmPrinter.cpp | 8 ++++---- X86AsmPrinter.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.146 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.147 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.146 Mon Nov 21 00:46:22 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Mon Nov 21 00:55:27 2005 @@ -120,7 +120,7 @@ if (C->isNullValue() && (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || I->hasWeakLinkage() /* FIXME: Verify correct */)) { - SwitchSection(O, CurSection, ".data"); + switchSection(O, CurSection, ".data"); if (!forCygwin && !forDarwin && I->hasInternalLinkage()) O << "\t.local " << name << "\n"; if (forDarwin && I->hasInternalLinkage()) @@ -139,7 +139,7 @@ case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. // Nonnull linkonce -> weak O << "\t.weak " << name << "\n"; - SwitchSection(O, CurSection, ""); + switchSection(O, CurSection, ""); O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\", at progbits\n"; break; case GlobalValue::AppendingLinkage: @@ -151,9 +151,9 @@ // FALL THROUGH case GlobalValue::InternalLinkage: if (C->isNullValue()) - SwitchSection(O, CurSection, ".bss"); + switchSection(O, CurSection, ".bss"); else - SwitchSection(O, CurSection, ".data"); + switchSection(O, CurSection, ".data"); break; } Index: llvm/lib/Target/X86/X86AsmPrinter.h diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.2 llvm/lib/Target/X86/X86AsmPrinter.h:1.3 --- llvm/lib/Target/X86/X86AsmPrinter.h:1.2 Thu Jul 7 19:23:26 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.h Mon Nov 21 00:55:27 2005 @@ -56,9 +56,9 @@ MI->getOperand(Op+3).isGlobalAddress()); } - // SwitchSection - Switch to the specified section of the executable if we are + // switchSection - Switch to the specified section of the executable if we are // not already in it! - inline static void SwitchSection(std::ostream &OS, std::string &CurSection, + inline static void switchSection(std::ostream &OS, std::string &CurSection, const char *NewSection) { if (CurSection != NewSection) { CurSection = NewSection; From lattner at cs.uiuc.edu Mon Nov 21 00:55:40 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 00:55:40 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Message-ID: <200511210655.AAA03510@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaAsmPrinter.cpp updated: 1.21 -> 1.22 --- Log message: Rename SwitchSection -> switchSection to avoid conflicting with a future change. --- Diffs of the changes: (+10 -10) AlphaAsmPrinter.cpp | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) Index: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp diff -u llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.21 llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.22 --- llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.21 Mon Nov 21 00:51:52 2005 +++ llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Mon Nov 21 00:55:27 2005 @@ -66,7 +66,7 @@ bool runOnMachineFunction(MachineFunction &F); bool doInitialization(Module &M); bool doFinalization(Module &M); - void SwitchSection(std::ostream &OS, const char *NewSection); + void switchSection(std::ostream &OS, const char *NewSection); }; } // end of anonymous namespace @@ -180,7 +180,7 @@ printConstantPool(MF.getConstantPool()); // Print out labels for the function. - SwitchSection(O, "text"); + switchSection(O, "text"); emitAlignment(4); O << "\t.globl " << CurrentFnName << "\n"; O << "\t.ent " << CurrentFnName << "\n"; @@ -220,9 +220,9 @@ if (CP.empty()) return; - SwitchSection(O, "rodata"); + switchSection(O, "rodata"); for (unsigned i = 0, e = CP.size(); i != e; ++i) { - // SwitchSection(O, "section .rodata, \"dr\""); + // switchSection(O, "section .rodata, \"dr\""); emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n"; @@ -243,10 +243,10 @@ } -// SwitchSection - Switch to the specified section of the executable if we are +// switchSection - Switch to the specified section of the executable if we are // not already in it! // -void AlphaAsmPrinter::SwitchSection(std::ostream &OS, const char *NewSection) +void AlphaAsmPrinter::switchSection(std::ostream &OS, const char *NewSection) { if (CurSection != NewSection) { CurSection = NewSection; @@ -269,7 +269,7 @@ if (C->isNullValue() && (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || I->hasWeakLinkage() /* FIXME: Verify correct */)) { - SwitchSection(O, "data"); + switchSection(O, "data"); if (I->hasInternalLinkage()) O << "\t.local " << name << "\n"; @@ -284,7 +284,7 @@ case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. // Nonnull linkonce -> weak O << "\t.weak " << name << "\n"; - SwitchSection(O, ""); + switchSection(O, ""); O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\", at progbits\n"; break; case GlobalValue::AppendingLinkage: @@ -296,9 +296,9 @@ // FALL THROUGH case GlobalValue::InternalLinkage: if (C->isNullValue()) - SwitchSection(O, "bss"); + switchSection(O, "bss"); else - SwitchSection(O, "data"); + switchSection(O, "data"); break; case GlobalValue::GhostLinkage: std::cerr << "GhostLinkage cannot appear in AlphaAsmPrinter!\n"; From lattner at cs.uiuc.edu Mon Nov 21 01:05:54 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:05:54 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h Message-ID: <200511210705.BAA03656@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: AsmPrinter.h updated: 1.16 -> 1.17 --- Log message: Add section switching to to common AsmPrinter code. --- Diffs of the changes: (+13 -0) AsmPrinter.h | 13 +++++++++++++ 1 files changed, 13 insertions(+) Index: llvm/include/llvm/CodeGen/AsmPrinter.h diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.16 llvm/include/llvm/CodeGen/AsmPrinter.h:1.17 --- llvm/include/llvm/CodeGen/AsmPrinter.h:1.16 Mon Nov 21 00:41:08 2005 +++ llvm/include/llvm/CodeGen/AsmPrinter.h Mon Nov 21 01:05:42 2005 @@ -24,6 +24,9 @@ class Mangler; class AsmPrinter : public MachineFunctionPass { + /// CurrentSection - The current section we are emitting to. This is + /// controlled and used by the SwitchSection method. + std::string CurrentSection; protected: /// Output stream on which we're printing assembly code. /// @@ -128,6 +131,16 @@ AlignmentIsInBytes(true) { } + /// SwitchSection - Switch to the specified section of the executable if we + /// are not already in it! If GV is non-null and if the global has an + /// explicitly requested section, we switch to the section indicated for the + /// global instead of NewSection. + /// + /// If the new section is an empty string, this method forgets what the + /// current section is, but does not emit a .section directive. + /// + void SwitchSection(const char *NewSection, const GlobalValue *GV); + /// doInitialization - Set up the AsmPrinter when we are working on a new /// module. If your pass overrides this, it must make sure to explicitly /// call this implementation. From lattner at cs.uiuc.edu Mon Nov 21 01:06:39 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:06:39 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp LiveVariables.cpp RegAllocLinearScan.cpp Message-ID: <200511210706.BAA03723@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: AsmPrinter.cpp updated: 1.25 -> 1.26 LiveVariables.cpp updated: 1.52 -> 1.53 RegAllocLinearScan.cpp updated: 1.114 -> 1.115 --- Log message: Add section switching to common code generator code. Add a couple of asserts. --- Diffs of the changes: (+23 -2) AsmPrinter.cpp | 19 +++++++++++++++++++ LiveVariables.cpp | 5 +++-- RegAllocLinearScan.cpp | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/AsmPrinter.cpp diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.25 llvm/lib/CodeGen/AsmPrinter.cpp:1.26 --- llvm/lib/CodeGen/AsmPrinter.cpp:1.25 Mon Nov 14 18:03:16 2005 +++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Nov 21 01:06:27 2005 @@ -19,8 +19,27 @@ #include "llvm/Target/TargetMachine.h" using namespace llvm; +/// SwitchSection - Switch to the specified section of the executable if we +/// are not already in it! +/// +void AsmPrinter::SwitchSection(const char *NewSection, const GlobalValue *GV) { + std::string NS; + + if (GV && GV->hasSection()) + NS = ".section " + GV->getSection(); + else + NS = NewSection; + + if (CurrentSection != NS) { + CurrentSection = NS; + if (!CurrentSection.empty()) + O << "\t" << CurrentSection << "\n"; + } +} + bool AsmPrinter::doInitialization(Module &M) { Mang = new Mangler(M, GlobalPrefix); + SwitchSection("", 0); // Reset back to no section. return false; } Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.52 llvm/lib/CodeGen/LiveVariables.cpp:1.53 --- llvm/lib/CodeGen/LiveVariables.cpp:1.52 Tue Aug 23 19:09:33 2005 +++ llvm/lib/CodeGen/LiveVariables.cpp Mon Nov 21 01:06:27 2005 @@ -278,10 +278,11 @@ MachineOperand &MO = MI->getOperand(i); if (!MO.getVRegValueOrNull()) { VarInfo &VRInfo = getVarInfo(MO.getReg()); + assert(VRInfo.DefInst && "Register use before def (or no def)!"); - // Only mark it alive only in the block we are representing... + // Only mark it alive only in the block we are representing. MarkVirtRegAliveInBlock(VRInfo, MBB); - break; // Found the PHI entry for this block... + break; // Found the PHI entry for this block. } } } Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.114 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.115 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.114 Tue Sep 20 23:19:09 2005 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Mon Nov 21 01:06:27 2005 @@ -547,6 +547,7 @@ minReg = reg; } } + assert(minReg && "Didn't find any reg!"); DEBUG(std::cerr << "\t\tregister with min weight: " << mri_->getName(minReg) << " (" << minWeight << ")\n"); From lattner at cs.uiuc.edu Mon Nov 21 01:07:10 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:07:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Message-ID: <200511210707.BAA03780@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCAsmPrinter.cpp updated: 1.114 -> 1.115 --- Log message: This is now implemented in common codegen code --- Diffs of the changes: (+0 -20) PPCAsmPrinter.cpp | 20 -------------------- 1 files changed, 20 deletions(-) Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.114 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.115 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.114 Mon Nov 21 00:47:58 2005 +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Mon Nov 21 01:06:58 2005 @@ -44,7 +44,6 @@ Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed"); class PPCAsmPrinter : public AsmPrinter { - std::string CurSection; public: std::set FnStubs, GVStubs, LinkOnceStubs; @@ -63,24 +62,6 @@ return static_cast(TM); } - /// SwitchSection - Switch to the specified section of the executable if we - /// are not already in it! - /// - void SwitchSection(const char *NewSection, const GlobalValue *GV) { - std::string NS; - - if (GV && GV->hasSection()) - NS = ".section " + GV->getSection(); - else - NS = NewSection; - - if (CurSection != NS) { - CurSection = NS; - if (!CurSection.empty()) - O << "\t" << CurSection << "\n"; - } - } - unsigned enumRegToMachineReg(unsigned enumReg) { switch (enumReg) { default: assert(0 && "Unhandled register!"); break; @@ -466,7 +447,6 @@ bool DarwinAsmPrinter::doInitialization(Module &M) { if (TM.getSubtarget().isGigaProcessor()) O << "\t.machine ppc970\n"; - SwitchSection("", 0); AsmPrinter::doInitialization(M); // Darwin wants symbols to be quoted if they have complex names. From lattner at cs.uiuc.edu Mon Nov 21 01:11:24 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:11:24 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86AsmPrinter.cpp X86AsmPrinter.h Message-ID: <200511210711.BAA03860@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86AsmPrinter.cpp updated: 1.147 -> 1.148 X86AsmPrinter.h updated: 1.3 -> 1.4 --- Log message: Start using the AsmPrinter shared SwitchSection code. This allows the X86 backend to implement global variables in sections. --- Diffs of the changes: (+3 -18) X86AsmPrinter.cpp | 10 +++------- X86AsmPrinter.h | 11 ----------- 2 files changed, 3 insertions(+), 18 deletions(-) Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.147 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.148 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.147 Mon Nov 21 00:55:27 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Mon Nov 21 01:11:11 2005 @@ -105,7 +105,6 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { const TargetData &TD = TM.getTargetData(); - std::string CurSection; // Print out module-level global variables here. for (Module::const_global_iterator I = M.global_begin(), @@ -120,7 +119,7 @@ if (C->isNullValue() && (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || I->hasWeakLinkage() /* FIXME: Verify correct */)) { - switchSection(O, CurSection, ".data"); + SwitchSection(".data", I); if (!forCygwin && !forDarwin && I->hasInternalLinkage()) O << "\t.local " << name << "\n"; if (forDarwin && I->hasInternalLinkage()) @@ -139,8 +138,8 @@ case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. // Nonnull linkonce -> weak O << "\t.weak " << name << "\n"; - switchSection(O, CurSection, ""); O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\", at progbits\n"; + SwitchSection("", I); break; case GlobalValue::AppendingLinkage: // FIXME: appending linkage variables should go into a section of @@ -150,10 +149,7 @@ O << "\t.globl " << name << "\n"; // FALL THROUGH case GlobalValue::InternalLinkage: - if (C->isNullValue()) - switchSection(O, CurSection, ".bss"); - else - switchSection(O, CurSection, ".data"); + SwitchSection(C->isNullValue() ? ".bss" : ".data", I); break; } Index: llvm/lib/Target/X86/X86AsmPrinter.h diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.3 llvm/lib/Target/X86/X86AsmPrinter.h:1.4 --- llvm/lib/Target/X86/X86AsmPrinter.h:1.3 Mon Nov 21 00:55:27 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.h Mon Nov 21 01:11:11 2005 @@ -55,17 +55,6 @@ MI->getOperand(Op+2).isRegister() && (MI->getOperand(Op+3).isImmediate()|| MI->getOperand(Op+3).isGlobalAddress()); } - - // switchSection - Switch to the specified section of the executable if we are - // not already in it! - inline static void switchSection(std::ostream &OS, std::string &CurSection, - const char *NewSection) { - if (CurSection != NewSection) { - CurSection = NewSection; - if (!CurSection.empty()) - OS << "\t" << NewSection << "\n"; - } - } }; } // end namespace x86 From lattner at cs.uiuc.edu Mon Nov 21 01:16:46 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:16:46 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86AsmPrinter.cpp X86IntelAsmPrinter.cpp Message-ID: <200511210716.BAA03961@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ATTAsmPrinter.cpp updated: 1.9 -> 1.10 X86AsmPrinter.cpp updated: 1.148 -> 1.149 X86IntelAsmPrinter.cpp updated: 1.5 -> 1.6 --- Log message: convert the rest of this over to use SwitchSection --- Diffs of the changes: (+4 -7) X86ATTAsmPrinter.cpp | 2 +- X86AsmPrinter.cpp | 7 ++----- X86IntelAsmPrinter.cpp | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.9 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.10 --- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.9 Mon Nov 21 00:46:22 2005 +++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Mon Nov 21 01:16:34 2005 @@ -32,7 +32,7 @@ printConstantPool(MF.getConstantPool()); // Print out labels for the function. - O << "\t.text\n"; + SwitchSection("\t.text\n", MF.getFunction()); emitAlignment(4); // FIXME: This should be parameterized somewhere. O << "\t.globl\t" << CurrentFnName << "\n"; if (!forCygwin && !forDarwin) Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.148 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.149 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.148 Mon Nov 21 01:11:11 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Mon Nov 21 01:16:34 2005 @@ -84,11 +84,7 @@ if (CP.empty()) return; - if (forDarwin) { - O << "\t.const\n"; - } else { - O << "\t.section .rodata\n"; - } + SwitchSection(forDarwin ? "\t.const\n" : "\t.section .rodata\n", 0); for (unsigned i = 0, e = CP.size(); i != e; ++i) { // FIXME: force doubles to be naturally aligned. We should handle this @@ -168,6 +164,7 @@ } if (forDarwin) { + SwitchSection("", 0); // Output stubs for external global variables if (GVStubs.begin() != GVStubs.end()) O << "\t.non_lazy_symbol_pointer\n"; Index: llvm/lib/Target/X86/X86IntelAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.5 llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.6 --- llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.5 Mon Nov 21 00:46:22 2005 +++ llvm/lib/Target/X86/X86IntelAsmPrinter.cpp Mon Nov 21 01:16:34 2005 @@ -32,7 +32,7 @@ printConstantPool(MF.getConstantPool()); // Print out labels for the function. - O << "\t.text\n"; + SwitchSection("\t.text\n", MF.getFunction()); emitAlignment(4); O << "\t.globl\t" << CurrentFnName << "\n"; if (!forCygwin && !forDarwin) From lattner at cs.uiuc.edu Mon Nov 21 01:26:16 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:26:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64AsmPrinter.cpp Message-ID: <200511210726.BAA04261@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64AsmPrinter.cpp updated: 1.15 -> 1.16 --- Log message: Start using SwitchSection, allowing globals and functions to be emitted to specific sections. Delete some dead functions copied from the X86 backend. --- Diffs of the changes: (+7 -39) IA64AsmPrinter.cpp | 46 +++++++--------------------------------------- 1 files changed, 7 insertions(+), 39 deletions(-) Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.15 llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.16 --- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.15 Mon Nov 21 00:55:27 2005 +++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Mon Nov 21 01:26:04 2005 @@ -46,33 +46,6 @@ }; } -static bool isScale(const MachineOperand &MO) { - return MO.isImmediate() && - (MO.getImmedValue() == 1 || MO.getImmedValue() == 2 || - MO.getImmedValue() == 4 || MO.getImmedValue() == 8); -} - -static bool isMem(const MachineInstr *MI, unsigned Op) { - if (MI->getOperand(Op).isFrameIndex()) return true; - if (MI->getOperand(Op).isConstantPoolIndex()) return true; - return Op+4 <= MI->getNumOperands() && - MI->getOperand(Op ).isRegister() && isScale(MI->getOperand(Op+1)) && - MI->getOperand(Op+2).isRegister() && (MI->getOperand(Op+3).isImmediate() || - MI->getOperand(Op+3).isGlobalAddress()); -} - -// switchSection - Switch to the specified section of the executable if we are -// not already in it! -// -static void switchSection(std::ostream &OS, std::string &CurSection, - const char *NewSection) { - if (CurSection != NewSection) { - CurSection = NewSection; - if (!CurSection.empty()) - OS << "\t" << NewSection << "\n"; - } -} - /// printConstantPool - Print to the current output stream assembly /// representations of the constants in the constant pool MCP. This is /// used to print out constants which have been "spilled to memory" by @@ -84,8 +57,8 @@ if (CP.empty()) return; - O << "\n\t.section .data, \"aw\", \"progbits\"\n"; - // FIXME: would be nice to have rodata (no 'w') when appropriate? + // FIXME: would be nice to have rodata (no 'w') when appropriate? + SwitchSection("\n\t.section .data, \"aw\", \"progbits\"\n", 0); for (unsigned i = 0, e = CP.size(); i != e; ++i) { emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i @@ -96,7 +69,6 @@ bool IA64SharedAsmPrinter::doFinalization(Module &M) { const TargetData &TD = TM.getTargetData(); - std::string CurSection; // Print out module-level global variables here. for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); @@ -111,7 +83,7 @@ if (C->isNullValue() && (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || I->hasWeakLinkage() /* FIXME: Verify correct */)) { - switchSection(O, CurSection, ".data"); + SwitchSection(".data", I); if (I->hasInternalLinkage()) { O << "\t.lcomm " << name << "," << TD.getTypeSize(C->getType()) << "," << (1 << Align); @@ -129,9 +101,9 @@ case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. // Nonnull linkonce -> weak O << "\t.weak " << name << "\n"; - switchSection(O, CurSection, ""); O << "\t.section\t.llvm.linkonce.d." << name << ", \"aw\", \"progbits\"\n"; + SwitchSection("", I); break; case GlobalValue::AppendingLinkage: // FIXME: appending linkage variables should go into a section of @@ -141,10 +113,7 @@ O << "\t.global " << name << "\n"; // FALL THROUGH case GlobalValue::InternalLinkage: - if (C->isNullValue()) - switchSection(O, CurSection, ".bss"); - else - switchSection(O, CurSection, ".data"); + SwitchSection(C->isNullValue() ? ".bss" : ".data", I); break; case GlobalValue::GhostLinkage: std::cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n"; @@ -298,8 +267,8 @@ printConstantPool(MF.getConstantPool()); // Print out labels for the function. - O << "\n\t.section .text, \"ax\", \"progbits\"\n"; - // ^^ means "Allocated instruXions in mem, initialized" + SwitchSection("\n\t.section .text, \"ax\", \"progbits\"\n", MF.getFunction()); + // ^^ means "Allocated instruXions in mem, initialized" emitAlignment(5); O << "\t.global\t" << CurrentFnName << "\n"; O << "\t.type\t" << CurrentFnName << ", @function\n"; @@ -413,7 +382,6 @@ /// MI to the current output stream. /// void IA64AsmPrinter::printMachineInstruction(const MachineInstr *MI) { - ++EmittedInsts; // Call the autogenerated instruction printer routines. From lattner at cs.uiuc.edu Mon Nov 21 01:30:41 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:30:41 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Message-ID: <200511210730.BAA04385@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaAsmPrinter.cpp updated: 1.22 -> 1.23 --- Log message: Switch to the new shared SwitchSection --- Diffs of the changes: (+6 -26) AlphaAsmPrinter.cpp | 32 ++++++-------------------------- 1 files changed, 6 insertions(+), 26 deletions(-) Index: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp diff -u llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.22 llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.23 --- llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.22 Mon Nov 21 00:55:27 2005 +++ llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Mon Nov 21 01:30:28 2005 @@ -21,12 +21,9 @@ #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/CodeGen/AsmPrinter.h" - #include "llvm/Target/TargetMachine.h" - #include "llvm/Support/Mangler.h" #include "llvm/ADT/Statistic.h" -#include "llvm/Support/CommandLine.h" using namespace llvm; @@ -66,7 +63,6 @@ bool runOnMachineFunction(MachineFunction &F); bool doInitialization(Module &M); bool doFinalization(Module &M); - void switchSection(std::ostream &OS, const char *NewSection); }; } // end of anonymous namespace @@ -180,7 +176,7 @@ printConstantPool(MF.getConstantPool()); // Print out labels for the function. - switchSection(O, "text"); + SwitchSection("\t.section .text", MF.getFunction()); emitAlignment(4); O << "\t.globl " << CurrentFnName << "\n"; O << "\t.ent " << CurrentFnName << "\n"; @@ -220,9 +216,8 @@ if (CP.empty()) return; - switchSection(O, "rodata"); + SwitchSection("\t.section .rodata", 0); for (unsigned i = 0, e = CP.size(); i != e; ++i) { - // switchSection(O, "section .rodata, \"dr\""); emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n"; @@ -242,19 +237,6 @@ return false; } - -// switchSection - Switch to the specified section of the executable if we are -// not already in it! -// -void AlphaAsmPrinter::switchSection(std::ostream &OS, const char *NewSection) -{ - if (CurSection != NewSection) { - CurSection = NewSection; - if (!CurSection.empty()) - OS << "\t.section ." << NewSection << "\n"; - } -} - bool AlphaAsmPrinter::doFinalization(Module &M) { const TargetData &TD = TM.getTargetData(); @@ -269,7 +251,7 @@ if (C->isNullValue() && (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || I->hasWeakLinkage() /* FIXME: Verify correct */)) { - switchSection(O, "data"); + SwitchSection("\t.section .data", I); if (I->hasInternalLinkage()) O << "\t.local " << name << "\n"; @@ -284,8 +266,8 @@ case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. // Nonnull linkonce -> weak O << "\t.weak " << name << "\n"; - switchSection(O, ""); O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\", at progbits\n"; + SwitchSection("", I); break; case GlobalValue::AppendingLinkage: // FIXME: appending linkage variables should go into a section of @@ -295,10 +277,8 @@ O << "\t.globl " << name << "\n"; // FALL THROUGH case GlobalValue::InternalLinkage: - if (C->isNullValue()) - switchSection(O, "bss"); - else - switchSection(O, "data"); + SwitchSection(C->isNullValue() ? "\t.section .bss" : + "\t.section .data", I); break; case GlobalValue::GhostLinkage: std::cerr << "GhostLinkage cannot appear in AlphaAsmPrinter!\n"; From lattner at cs.uiuc.edu Mon Nov 21 01:38:20 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:38:20 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Message-ID: <200511210738.BAA04507@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaAsmPrinter.cpp updated: 1.23 -> 1.24 --- Log message: Use PrivateGlobalPrefix for basic blocks --- Diffs of the changes: (+6 -6) AlphaAsmPrinter.cpp | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) Index: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp diff -u llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.23 llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.24 --- llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.23 Mon Nov 21 01:30:28 2005 +++ llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Mon Nov 21 01:38:08 2005 @@ -37,8 +37,7 @@ unsigned LabelNumber; AlphaAsmPrinter(std::ostream &o, TargetMachine &tm) - : AsmPrinter(o, tm), LabelNumber(0) - { + : AsmPrinter(o, tm), LabelNumber(0) { AlignmentIsInBytes = false; PrivateGlobalPrefix = "$"; } @@ -121,7 +120,8 @@ case MachineOperand::MO_MachineBasicBlock: { MachineBasicBlock *MBBOp = MO.getMachineBasicBlock(); - O << "$LBB" << Mang->getValueName(MBBOp->getParent()->getFunction()) + O << PrivateGlobalPrefix << "LBB" + << Mang->getValueName(MBBOp->getParent()->getFunction()) << "_" << MBBOp->getNumber() << "\t" << CommentString << " " << MBBOp->getBasicBlock()->getName(); return; @@ -140,7 +140,7 @@ //Abuse PCrel to specify pcrel calls //calls are the only thing that use this flag if (MO.isPCRelative()) - O << "$" << Mang->getValueName(MO.getGlobal()) << "..ng"; + O << PrivateGlobalPrefix << Mang->getValueName(MO.getGlobal()) << "..ng"; else O << Mang->getValueName(MO.getGlobal()); return; @@ -187,8 +187,8 @@ for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { // Print a label for the basic block. - O << "$LBB" << CurrentFnName << "_" << I->getNumber() << ":\t" - << CommentString << " " << I->getBasicBlock()->getName() << "\n"; + O << PrivateGlobalPrefix << "LBB" << CurrentFnName << "_" << I->getNumber() + << ":\t" << CommentString << " " << I->getBasicBlock()->getName() << "\n"; for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); II != E; ++II) { // Print the assembly for the instruction. From lattner at cs.uiuc.edu Mon Nov 21 01:39:34 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:39:34 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64AsmPrinter.cpp Message-ID: <200511210739.BAA04571@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64AsmPrinter.cpp updated: 1.16 -> 1.17 --- Log message: Use PrivateGlobalPrefix for basic block labels --- Diffs of the changes: (+4 -2) IA64AsmPrinter.cpp | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.16 llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.17 --- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.16 Mon Nov 21 01:26:04 2005 +++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Mon Nov 21 01:39:22 2005 @@ -279,7 +279,8 @@ I != E; ++I) { // Print a label for the basic block if there are any predecessors. if (I->pred_begin() != I->pred_end()) - O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t" + O << PrivateGlobalPrefix << "LBB" << CurrentFnName << "_" + << I->getNumber() << ":\t" << CommentString << " " << I->getBasicBlock()->getName() << "\n"; for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); II != E; ++II) { @@ -315,7 +316,8 @@ return; case MachineOperand::MO_MachineBasicBlock: { MachineBasicBlock *MBBOp = MO.getMachineBasicBlock(); - O << ".LBB" << Mang->getValueName(MBBOp->getParent()->getFunction()) + O << PrivateGlobalPrefix << "LBB" + << Mang->getValueName(MBBOp->getParent()->getFunction()) << "_" << MBBOp->getNumber () << "\t// " << MBBOp->getBasicBlock ()->getName (); return; From lattner at cs.uiuc.edu Mon Nov 21 01:41:17 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:41:17 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Message-ID: <200511210741.BAA04634@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCAsmPrinter.cpp updated: 1.115 -> 1.116 --- Log message: use PrivateGlobalPrefix for basic blocks --- Diffs of the changes: (+6 -5) PPCAsmPrinter.cpp | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.115 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.116 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.115 Mon Nov 21 01:06:58 2005 +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Mon Nov 21 01:41:05 2005 @@ -302,8 +302,8 @@ case MachineOperand::MO_MachineBasicBlock: { MachineBasicBlock *MBBOp = MO.getMachineBasicBlock(); - O << "LBB" << FunctionNumber << "_" << MBBOp->getNumber() << "\t; " - << MBBOp->getBasicBlock()->getName(); + O << PrivateGlobalPrefix << "BB" << FunctionNumber << "_" + << MBBOp->getNumber() << "\t; " << MBBOp->getBasicBlock()->getName(); return; } @@ -401,7 +401,8 @@ I != E; ++I) { // Print a label for the basic block. if (I != MF.begin()) { - O << "LBB" << FunctionNumber << '_' << I->getNumber() << ":\t"; + O << PrivateGlobalPrefix << "BB" << FunctionNumber << '_' + << I->getNumber() << ":\t"; if (!I->getBasicBlock()->getName().empty()) O << CommentString << " " << I->getBasicBlock()->getName(); O << "\n"; @@ -608,8 +609,8 @@ for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { // Print a label for the basic block. - O << "LBB" << CurrentFnName << '_' << I->getNumber() << ":\t# " - << I->getBasicBlock()->getName() << '\n'; + O << PrivateGlobalPrefix << "BB" << CurrentFnName << '_' << I->getNumber() + << ":\t# " << I->getBasicBlock()->getName() << '\n'; for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); II != E; ++II) { // Print the assembly for the instruction. From lattner at cs.uiuc.edu Mon Nov 21 01:44:12 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:44:12 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86IntelAsmPrinter.cpp Message-ID: <200511210744.BAA04702@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ATTAsmPrinter.cpp updated: 1.10 -> 1.11 X86IntelAsmPrinter.cpp updated: 1.6 -> 1.7 --- Log message: Use PrivateGlobalPrefix for basic block labels. This allows the x86 darwin port to properly use L for the bb prefix instead of . --- Diffs of the changes: (+9 -5) X86ATTAsmPrinter.cpp | 8 +++++--- X86IntelAsmPrinter.cpp | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.10 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.11 --- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.10 Mon Nov 21 01:16:34 2005 +++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Mon Nov 21 01:43:59 2005 @@ -44,8 +44,9 @@ I != E; ++I) { // Print a label for the basic block. if (I->pred_begin() != I->pred_end()) - O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t" - << CommentString << " " << I->getBasicBlock()->getName() << "\n"; + O << PrivateGlobalPrefix << "BB" << CurrentFnName << "_" << I->getNumber() + << ":\t" << CommentString << " " << I->getBasicBlock()->getName() + << "\n"; for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); II != E; ++II) { // Print the assembly for the instruction. @@ -78,7 +79,8 @@ return; case MachineOperand::MO_MachineBasicBlock: { MachineBasicBlock *MBBOp = MO.getMachineBasicBlock(); - O << ".LBB" << Mang->getValueName(MBBOp->getParent()->getFunction()) + O << PrivateGlobalPrefix << "BB" + << Mang->getValueName(MBBOp->getParent()->getFunction()) << "_" << MBBOp->getNumber () << "\t# " << MBBOp->getBasicBlock ()->getName (); return; Index: llvm/lib/Target/X86/X86IntelAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.6 llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.7 --- llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.6 Mon Nov 21 01:16:34 2005 +++ llvm/lib/Target/X86/X86IntelAsmPrinter.cpp Mon Nov 21 01:43:59 2005 @@ -44,7 +44,8 @@ I != E; ++I) { // Print a label for the basic block if there are any predecessors. if (I->pred_begin() != I->pred_end()) - O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t" + O << PrivateGlobalPrefix << "BB" << CurrentFnName << "_" << I->getNumber() + << ":\t" << CommentString << " " << I->getBasicBlock()->getName() << "\n"; for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); II != E; ++II) { @@ -98,7 +99,8 @@ return; case MachineOperand::MO_MachineBasicBlock: { MachineBasicBlock *MBBOp = MO.getMachineBasicBlock(); - O << ".LBB" << Mang->getValueName(MBBOp->getParent()->getFunction()) + O << PrivateGlobalPrefix << "BB" + << Mang->getValueName(MBBOp->getParent()->getFunction()) << "_" << MBBOp->getNumber () << "\t# " << MBBOp->getBasicBlock ()->getName (); return; From lattner at cs.uiuc.edu Mon Nov 21 01:51:19 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:51:19 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h Message-ID: <200511210751.BAA04817@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: AsmPrinter.h updated: 1.17 -> 1.18 --- Log message: Capitalize methods for better consistency --- Diffs of the changes: (+10 -10) AsmPrinter.h | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) Index: llvm/include/llvm/CodeGen/AsmPrinter.h diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.17 llvm/include/llvm/CodeGen/AsmPrinter.h:1.18 --- llvm/include/llvm/CodeGen/AsmPrinter.h:1.17 Mon Nov 21 01:05:42 2005 +++ llvm/include/llvm/CodeGen/AsmPrinter.h Mon Nov 21 01:51:06 2005 @@ -150,27 +150,27 @@ /// pass, you must make sure to call it explicitly. bool doFinalization(Module &M); - /// setupMachineFunction - This should be called when a new MachineFunction + /// SetupMachineFunction - This should be called when a new MachineFunction /// is being processed from runOnMachineFunction. - void setupMachineFunction(MachineFunction &MF); + void SetupMachineFunction(MachineFunction &MF); - /// emitAlignment - Emit an alignment directive to the specified power of + /// EmitAlignment - Emit an alignment directive to the specified power of /// two boundary. For example, if you pass in 3 here, you will get an 8 /// byte alignment. If a global value is specified, and if that global has /// an explicit alignment requested, it will override the alignment request. - void emitAlignment(unsigned NumBits, const GlobalValue *GV = 0) const; + void EmitAlignment(unsigned NumBits, const GlobalValue *GV = 0) const; - /// emitZeros - Emit a block of zeros. + /// EmitZeros - Emit a block of zeros. /// - void emitZeros(uint64_t NumZeros) const; + void EmitZeros(uint64_t NumZeros) const; - /// emitConstantValueOnly - Print out the specified constant, without a + /// EmitConstantValueOnly - Print out the specified constant, without a /// storage class. Only constants of first-class type are allowed here. - void emitConstantValueOnly(const Constant *CV); + void EmitConstantValueOnly(const Constant *CV); - /// emitGlobalConstant - Print a general LLVM constant to the .s file. + /// EmitGlobalConstant - Print a general LLVM constant to the .s file. /// - void emitGlobalConstant(const Constant* CV); + void EmitGlobalConstant(const Constant* CV); }; } From lattner at cs.uiuc.edu Mon Nov 21 01:51:36 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:51:36 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Message-ID: <200511210751.BAA04873@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCAsmPrinter.cpp updated: 1.116 -> 1.117 --- Log message: Adjust to capitalized AsmPrinter method names --- Diffs of the changes: (+11 -11) PPCAsmPrinter.cpp | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.116 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.117 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.116 Mon Nov 21 01:41:05 2005 +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Mon Nov 21 01:51:23 2005 @@ -382,7 +382,7 @@ /// method to print assembly for each instruction. /// bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) { - setupMachineFunction(MF); + SetupMachineFunction(MF); O << "\n\n"; // Print out constants referenced by the function @@ -391,7 +391,7 @@ // Print out labels for the function. const Function *F = MF.getFunction(); SwitchSection(".text", F); - emitAlignment(4, F); + EmitAlignment(4, F); if (!F->hasInternalLinkage()) O << "\t.globl\t" << CurrentFnName << "\n"; O << CurrentFnName << ":\n"; @@ -436,12 +436,12 @@ // FIXME: force doubles to be naturally aligned. We should handle this // more correctly in the future. if (CP[i]->getType() == Type::DoubleTy) - emitAlignment(3); + EmitAlignment(3); else - emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); + EmitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n'; - emitGlobalConstant(CP[i]); + EmitGlobalConstant(CP[i]); } } @@ -507,9 +507,9 @@ abort(); } - emitAlignment(Align, I); + EmitAlignment(Align, I); O << name << ":\t\t\t\t; '" << I->getName() << "'\n"; - emitGlobalConstant(C); + EmitGlobalConstant(C); } } @@ -520,7 +520,7 @@ if (PICEnabled) { O << ".data\n"; O << ".section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32\n"; - emitAlignment(2); + EmitAlignment(2); O << "L" << *i << "$stub:\n"; O << "\t.indirect_symbol " << *i << "\n"; O << "\tmflr r0\n"; @@ -539,7 +539,7 @@ O << "\t.long dyld_stub_binding_helper\n"; } else { O << "\t.section __TEXT,__symbol_stub1,symbol_stubs,pure_instructions,16\n"; - emitAlignment(4); + EmitAlignment(4); O << "L" << *i << "$stub:\n"; O << "\t.indirect_symbol " << *i << "\n"; O << "\tlis r11,ha16(L" << *i << "$lazy_ptr)\n"; @@ -649,7 +649,7 @@ << "\n"; O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i << ":\t\t\t\t\t;" << *CP[i] << '\n'; - emitGlobalConstant(CP[i]); + EmitGlobalConstant(CP[i]); } } @@ -677,7 +677,7 @@ O << "\t.csect _global.rw_c[RW],3\n"; } O << Name << ":\n"; - emitGlobalConstant(C); + EmitGlobalConstant(C); } // Output labels for globals From lattner at cs.uiuc.edu Mon Nov 21 01:51:36 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:51:36 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64AsmPrinter.cpp Message-ID: <200511210751.BAA04880@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64AsmPrinter.cpp updated: 1.17 -> 1.18 --- Log message: Adjust to capitalized AsmPrinter method names --- Diffs of the changes: (+6 -6) IA64AsmPrinter.cpp | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.17 llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.18 --- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.17 Mon Nov 21 01:39:22 2005 +++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Mon Nov 21 01:51:23 2005 @@ -60,10 +60,10 @@ // FIXME: would be nice to have rodata (no 'w') when appropriate? SwitchSection("\n\t.section .data, \"aw\", \"progbits\"\n", 0); for (unsigned i = 0, e = CP.size(); i != e; ++i) { - emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); + EmitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n"; - emitGlobalConstant(CP[i]); + EmitGlobalConstant(CP[i]); } } @@ -120,7 +120,7 @@ abort(); } - emitAlignment(Align); + EmitAlignment(Align); O << "\t.type " << name << ", at object\n"; O << "\t.size " << name << "," << Size << "\n"; O << name << ":\t\t\t\t// "; @@ -128,7 +128,7 @@ O << " = "; WriteAsOperand(O, C, false, false, &M); O << "\n"; - emitGlobalConstant(C); + EmitGlobalConstant(C); } } @@ -260,7 +260,7 @@ /// method to print assembly for each instruction. /// bool IA64AsmPrinter::runOnMachineFunction(MachineFunction &MF) { - setupMachineFunction(MF); + SetupMachineFunction(MF); O << "\n\n"; // Print out constants referenced by the function @@ -269,7 +269,7 @@ // Print out labels for the function. SwitchSection("\n\t.section .text, \"ax\", \"progbits\"\n", MF.getFunction()); // ^^ means "Allocated instruXions in mem, initialized" - emitAlignment(5); + EmitAlignment(5); O << "\t.global\t" << CurrentFnName << "\n"; O << "\t.type\t" << CurrentFnName << ", @function\n"; O << CurrentFnName << ":\n"; From lattner at cs.uiuc.edu Mon Nov 21 01:51:37 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:51:37 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86AsmPrinter.cpp X86IntelAsmPrinter.cpp Message-ID: <200511210751.BAA04888@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ATTAsmPrinter.cpp updated: 1.11 -> 1.12 X86AsmPrinter.cpp updated: 1.149 -> 1.150 X86IntelAsmPrinter.cpp updated: 1.7 -> 1.8 --- Log message: Adjust to capitalized AsmPrinter method names --- Diffs of the changes: (+9 -9) X86ATTAsmPrinter.cpp | 4 ++-- X86AsmPrinter.cpp | 10 +++++----- X86IntelAsmPrinter.cpp | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.11 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.12 --- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.11 Mon Nov 21 01:43:59 2005 +++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Mon Nov 21 01:51:23 2005 @@ -25,7 +25,7 @@ /// method to print assembly for each instruction. /// bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) { - setupMachineFunction(MF); + SetupMachineFunction(MF); O << "\n\n"; // Print out constants referenced by the function @@ -33,7 +33,7 @@ // Print out labels for the function. SwitchSection("\t.text\n", MF.getFunction()); - emitAlignment(4); // FIXME: This should be parameterized somewhere. + EmitAlignment(4); // FIXME: This should be parameterized somewhere. O << "\t.globl\t" << CurrentFnName << "\n"; if (!forCygwin && !forDarwin) O << "\t.type\t" << CurrentFnName << ", @function\n"; Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.149 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.150 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.149 Mon Nov 21 01:16:34 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Mon Nov 21 01:51:23 2005 @@ -90,12 +90,12 @@ // FIXME: force doubles to be naturally aligned. We should handle this // more correctly in the future. if (CP[i]->getType() == Type::DoubleTy) - emitAlignment(3); + EmitAlignment(3); else - emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); + EmitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n"; - emitGlobalConstant(CP[i]); + EmitGlobalConstant(CP[i]); } } @@ -149,7 +149,7 @@ break; } - emitAlignment(Align); + EmitAlignment(Align); if (!forCygwin && !forDarwin) { O << "\t.type " << name << ", at object\n"; O << "\t.size " << name << "," << Size << "\n"; @@ -159,7 +159,7 @@ O << " = "; WriteAsOperand(O, C, false, false, &M); O << "\n"; - emitGlobalConstant(C); + EmitGlobalConstant(C); } } Index: llvm/lib/Target/X86/X86IntelAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.7 llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.8 --- llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.7 Mon Nov 21 01:43:59 2005 +++ llvm/lib/Target/X86/X86IntelAsmPrinter.cpp Mon Nov 21 01:51:23 2005 @@ -25,7 +25,7 @@ /// method to print assembly for each instruction. /// bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) { - setupMachineFunction(MF); + SetupMachineFunction(MF); O << "\n\n"; // Print out constants referenced by the function @@ -33,7 +33,7 @@ // Print out labels for the function. SwitchSection("\t.text\n", MF.getFunction()); - emitAlignment(4); + EmitAlignment(4); O << "\t.globl\t" << CurrentFnName << "\n"; if (!forCygwin && !forDarwin) O << "\t.type\t" << CurrentFnName << ", @function\n"; From lattner at cs.uiuc.edu Mon Nov 21 01:51:37 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:51:37 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Message-ID: <200511210751.BAA04892@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaAsmPrinter.cpp updated: 1.24 -> 1.25 --- Log message: Adjust to capitalized AsmPrinter method names --- Diffs of the changes: (+6 -6) AlphaAsmPrinter.cpp | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) Index: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp diff -u llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.24 llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.25 --- llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.24 Mon Nov 21 01:38:08 2005 +++ llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Mon Nov 21 01:51:23 2005 @@ -169,7 +169,7 @@ /// method to print assembly for each instruction. /// bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) { - setupMachineFunction(MF); + SetupMachineFunction(MF); O << "\n\n"; // Print out constants referenced by the function @@ -177,7 +177,7 @@ // Print out labels for the function. SwitchSection("\t.section .text", MF.getFunction()); - emitAlignment(4); + EmitAlignment(4); O << "\t.globl " << CurrentFnName << "\n"; O << "\t.ent " << CurrentFnName << "\n"; @@ -218,10 +218,10 @@ SwitchSection("\t.section .rodata", 0); for (unsigned i = 0, e = CP.size(); i != e; ++i) { - emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); + EmitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n"; - emitGlobalConstant(CP[i]); + EmitGlobalConstant(CP[i]); } } @@ -285,7 +285,7 @@ abort(); } - emitAlignment(Align); + EmitAlignment(Align); O << "\t.type " << name << ", at object\n"; O << "\t.size " << name << "," << Size << "\n"; O << name << ":\t\t\t\t# "; @@ -293,7 +293,7 @@ O << " = "; WriteAsOperand(O, C, false, false, &M); O << "\n"; - emitGlobalConstant(C); + EmitGlobalConstant(C); } } From lattner at cs.uiuc.edu Mon Nov 21 01:51:48 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:51:48 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp Message-ID: <200511210751.BAA04899@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: AsmPrinter.cpp updated: 1.26 -> 1.27 --- Log message: Adjust to capitalized asmprinter method names --- Diffs of the changes: (+18 -18) AsmPrinter.cpp | 36 ++++++++++++++++++------------------ 1 files changed, 18 insertions(+), 18 deletions(-) Index: llvm/lib/CodeGen/AsmPrinter.cpp diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.26 llvm/lib/CodeGen/AsmPrinter.cpp:1.27 --- llvm/lib/CodeGen/AsmPrinter.cpp:1.26 Mon Nov 21 01:06:27 2005 +++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Nov 21 01:51:36 2005 @@ -48,13 +48,13 @@ return false; } -void AsmPrinter::setupMachineFunction(MachineFunction &MF) { +void AsmPrinter::SetupMachineFunction(MachineFunction &MF) { // What's my mangled name? CurrentFnName = Mang->getValueName(MF.getFunction()); } -// emitAlignment - Emit an alignment directive to the specified power of two. -void AsmPrinter::emitAlignment(unsigned NumBits, const GlobalValue *GV) const { +// EmitAlignment - Emit an alignment directive to the specified power of two. +void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const { if (GV && GV->getAlignment()) NumBits = Log2_32(GV->getAlignment()); if (NumBits == 0) return; // No need to emit alignment. @@ -62,9 +62,9 @@ O << AlignDirective << NumBits << "\n"; } -/// emitZeros - Emit a block of zeros. +/// EmitZeros - Emit a block of zeros. /// -void AsmPrinter::emitZeros(uint64_t NumZeros) const { +void AsmPrinter::EmitZeros(uint64_t NumZeros) const { if (NumZeros) { if (ZeroDirective) O << ZeroDirective << NumZeros << "\n"; @@ -77,7 +77,7 @@ // Print out the specified constant, without a storage class. Only the // constants valid in constant expressions can occur here. -void AsmPrinter::emitConstantValueOnly(const Constant *CV) { +void AsmPrinter::EmitConstantValueOnly(const Constant *CV) { if (CV->isNullValue() || isa(CV)) O << "0"; else if (const ConstantBool *CB = dyn_cast(CV)) { @@ -109,13 +109,13 @@ if (int64_t Offset = TD.getIndexedOffset(ptrVal->getType(), idxVec)) { if (Offset) O << "("; - emitConstantValueOnly(ptrVal); + EmitConstantValueOnly(ptrVal); if (Offset > 0) O << ") + " << Offset; else if (Offset < 0) O << ") - " << -Offset; } else { - emitConstantValueOnly(ptrVal); + EmitConstantValueOnly(ptrVal); } break; } @@ -137,14 +137,14 @@ || (((TD.getTypeSize(Ty) >= TD.getTypeSize(OpTy)) && OpTy->isLosslesslyConvertibleTo(Ty)))) && "FIXME: Don't yet support this kind of constant cast expr"); - emitConstantValueOnly(Op); + EmitConstantValueOnly(Op); break; } case Instruction::Add: O << "("; - emitConstantValueOnly(CE->getOperand(0)); + EmitConstantValueOnly(CE->getOperand(0)); O << ") + ("; - emitConstantValueOnly(CE->getOperand(1)); + EmitConstantValueOnly(CE->getOperand(1)); O << ")"; break; default: @@ -198,13 +198,13 @@ O << "\""; } -/// emitGlobalConstant - Print a general LLVM constant to the .s file. +/// EmitGlobalConstant - Print a general LLVM constant to the .s file. /// -void AsmPrinter::emitGlobalConstant(const Constant *CV) { +void AsmPrinter::EmitGlobalConstant(const Constant *CV) { const TargetData &TD = TM.getTargetData(); if (CV->isNullValue() || isa(CV)) { - emitZeros(TD.getTypeSize(CV->getType())); + EmitZeros(TD.getTypeSize(CV->getType())); return; } else if (const ConstantArray *CVA = dyn_cast(CV)) { if (CVA->isString()) { @@ -220,7 +220,7 @@ O << "\n"; } else { // Not a string. Print the values in successive locations for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i) - emitGlobalConstant(CVA->getOperand(i)); + EmitGlobalConstant(CVA->getOperand(i)); } return; } else if (const ConstantStruct *CVS = dyn_cast(CV)) { @@ -238,10 +238,10 @@ sizeSoFar += fieldSize + padSize; // Now print the actual field value - emitGlobalConstant(field); + EmitGlobalConstant(field); // Insert the field padding unless it's zero bytes... - emitZeros(padSize); + EmitZeros(padSize); } assert(sizeSoFar == cvsLayout->StructSize && "Layout of constant struct may be incorrect!"); @@ -328,6 +328,6 @@ assert (0 && "Can't handle printing this type of thing"); break; } - emitConstantValueOnly(CV); + EmitConstantValueOnly(CV); O << "\n"; } From lattner at cs.uiuc.edu Mon Nov 21 01:57:48 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 01:57:48 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Message-ID: <200511210757.BAA05111@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCAsmPrinter.cpp updated: 1.117 -> 1.118 --- Log message: unify the darwin and aix constant pool printers --- Diffs of the changes: (+28 -48) PPCAsmPrinter.cpp | 76 +++++++++++++++++++----------------------------------- 1 files changed, 28 insertions(+), 48 deletions(-) Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.117 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.118 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.117 Mon Nov 21 01:51:23 2005 +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Mon Nov 21 01:57:37 2005 @@ -62,6 +62,8 @@ return static_cast(TM); } + void printConstantPool(MachineConstantPool *MCP); + unsigned enumRegToMachineReg(unsigned enumReg) { switch (enumReg) { default: assert(0 && "Unhandled register!"); break; @@ -197,7 +199,6 @@ O << (0x80 >> RegNo); } - virtual void printConstantPool(MachineConstantPool *MCP) = 0; virtual bool runOnMachineFunction(MachineFunction &F) = 0; virtual bool doFinalization(Module &M) = 0; }; @@ -221,7 +222,6 @@ return "Darwin PPC Assembly Printer"; } - void printConstantPool(MachineConstantPool *MCP); bool runOnMachineFunction(MachineFunction &F); bool doInitialization(Module &M); bool doFinalization(Module &M); @@ -247,7 +247,6 @@ return "AIX PPC Assembly Printer"; } - void printConstantPool(MachineConstantPool *MCP); bool runOnMachineFunction(MachineFunction &F); bool doInitialization(Module &M); bool doFinalization(Module &M); @@ -378,6 +377,32 @@ return; } +/// printConstantPool - Print to the current output stream assembly +/// representations of the constants in the constant pool MCP. This is +/// used to print out constants which have been "spilled to memory" by +/// the code generator. +/// +void PPCAsmPrinter::printConstantPool(MachineConstantPool *MCP) { + const std::vector &CP = MCP->getConstants(); + const TargetData &TD = TM.getTargetData(); + + if (CP.empty()) return; + + SwitchSection(".const", 0); + for (unsigned i = 0, e = CP.size(); i != e; ++i) { + // FIXME: force doubles to be naturally aligned. We should handle this + // more correctly in the future. + unsigned Alignment = TD.getTypeAlignmentShift(CP[i]->getType()); + if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3; + + EmitAlignment(Alignment); + O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i + << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n'; + EmitGlobalConstant(CP[i]); + } +} + + /// runOnMachineFunction - This uses the printMachineInstruction() /// method to print assembly for each instruction. /// @@ -420,30 +445,6 @@ return false; } -/// printConstantPool - Print to the current output stream assembly -/// representations of the constants in the constant pool MCP. This is -/// used to print out constants which have been "spilled to memory" by -/// the code generator. -/// -void DarwinAsmPrinter::printConstantPool(MachineConstantPool *MCP) { - const std::vector &CP = MCP->getConstants(); - const TargetData &TD = TM.getTargetData(); - - if (CP.empty()) return; - - SwitchSection(".const", 0); - for (unsigned i = 0, e = CP.size(); i != e; ++i) { - // FIXME: force doubles to be naturally aligned. We should handle this - // more correctly in the future. - if (CP[i]->getType() == Type::DoubleTy) - EmitAlignment(3); - else - EmitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); - O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i - << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n'; - EmitGlobalConstant(CP[i]); - } -} bool DarwinAsmPrinter::doInitialization(Module &M) { if (TM.getSubtarget().isGigaProcessor()) @@ -632,27 +633,6 @@ return false; } -/// printConstantPool - Print to the current output stream assembly -/// representations of the constants in the constant pool MCP. This is -/// used to print out constants which have been "spilled to memory" by -/// the code generator. -/// -void AIXAsmPrinter::printConstantPool(MachineConstantPool *MCP) { - const std::vector &CP = MCP->getConstants(); - const TargetData &TD = TM.getTargetData(); - - if (CP.empty()) return; - - for (unsigned i = 0, e = CP.size(); i != e; ++i) { - SwitchSection(".const", 0); - O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType()) - << "\n"; - O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i - << ":\t\t\t\t\t;" << *CP[i] << '\n'; - EmitGlobalConstant(CP[i]); - } -} - bool AIXAsmPrinter::doInitialization(Module &M) { SwitchSection("", 0); const TargetData &TD = TM.getTargetData(); From lattner at cs.uiuc.edu Mon Nov 21 02:02:53 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 02:02:53 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Message-ID: <200511210802.CAA05368@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCAsmPrinter.cpp updated: 1.118 -> 1.119 --- Log message: Use CommentString where possible, fix a bug where aix mode wouldn't assemble due to basic blocks being misnamed. --- Diffs of the changes: (+4 -4) PPCAsmPrinter.cpp | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.118 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.119 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.118 Mon Nov 21 01:57:37 2005 +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Mon Nov 21 02:02:41 2005 @@ -590,7 +590,7 @@ /// method to print assembly for each instruction. /// bool AIXAsmPrinter::runOnMachineFunction(MachineFunction &MF) { - CurrentFnName = MF.getFunction()->getName(); + SetupMachineFunction(MF); // Print out constants referenced by the function printConstantPool(MF.getConstantPool()); @@ -610,8 +610,8 @@ for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { // Print a label for the basic block. - O << PrivateGlobalPrefix << "BB" << CurrentFnName << '_' << I->getNumber() - << ":\t# " << I->getBasicBlock()->getName() << '\n'; + O << PrivateGlobalPrefix << "BB" << FunctionNumber << '_' << I->getNumber() + << ":\t" << CommentString << I->getBasicBlock()->getName() << '\n'; for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); II != E; ++II) { // Print the assembly for the instruction. @@ -697,7 +697,7 @@ O << "\t.comm " << Name << "," << TD.getTypeSize(I->getType()) << "," << Log2_32((unsigned)TD.getTypeAlignment(I->getType())); } - O << "\t\t# "; + O << "\t\t" << CommentString << " "; WriteAsOperand(O, I, false, true, &M); O << "\n"; } From lattner at cs.uiuc.edu Mon Nov 21 02:13:01 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 02:13:01 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h Message-ID: <200511210813.CAA05471@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: AsmPrinter.h updated: 1.18 -> 1.19 --- Log message: Make the AsmPrinter keep track of the notion of a function number. --- Diffs of the changes: (+19 -2) AsmPrinter.h | 21 +++++++++++++++++++-- 1 files changed, 19 insertions(+), 2 deletions(-) Index: llvm/include/llvm/CodeGen/AsmPrinter.h diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.18 llvm/include/llvm/CodeGen/AsmPrinter.h:1.19 --- llvm/include/llvm/CodeGen/AsmPrinter.h:1.18 Mon Nov 21 01:51:06 2005 +++ llvm/include/llvm/CodeGen/AsmPrinter.h Mon Nov 21 02:12:47 2005 @@ -27,6 +27,14 @@ /// CurrentSection - The current section we are emitting to. This is /// controlled and used by the SwitchSection method. std::string CurrentSection; + + /// FunctionNumber - This provides a unique ID for each function emitted in + /// this translation unit. It is autoincremented by SetupMachineFunction, + /// and can be accessed with getFunctionNumber() and + /// IncrementFunctionNumber(). + /// + unsigned FunctionNumber; + protected: /// Output stream on which we're printing assembly code. /// @@ -112,7 +120,7 @@ bool AlignmentIsInBytes; // Defaults to true AsmPrinter(std::ostream &o, TargetMachine &tm) - : O(o), TM(tm), + : FunctionNumber(0), O(o), TM(tm), CommentString("#"), GlobalPrefix(""), PrivateGlobalPrefix("."), @@ -140,7 +148,16 @@ /// current section is, but does not emit a .section directive. /// void SwitchSection(const char *NewSection, const GlobalValue *GV); - + + /// getFunctionNumber - Return a unique ID for the current function. + /// + unsigned getFunctionNumber() const { return FunctionNumber; } + + /// IncrementFunctionNumber - Increase Function Number. AsmPrinters should + /// not normally call this, as the counter is automatically bumped by + /// SetupMachineFunction. + void IncrementFunctionNumber() { FunctionNumber++; } + /// doInitialization - Set up the AsmPrinter when we are working on a new /// module. If your pass overrides this, it must make sure to explicitly /// call this implementation. From lattner at cs.uiuc.edu Mon Nov 21 02:13:39 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 02:13:39 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp Message-ID: <200511210813.CAA05530@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: AsmPrinter.cpp updated: 1.27 -> 1.28 --- Log message: increment the function number in SetupMachineFunction --- Diffs of the changes: (+1 -0) AsmPrinter.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm/lib/CodeGen/AsmPrinter.cpp diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.27 llvm/lib/CodeGen/AsmPrinter.cpp:1.28 --- llvm/lib/CodeGen/AsmPrinter.cpp:1.27 Mon Nov 21 01:51:36 2005 +++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Nov 21 02:13:27 2005 @@ -51,6 +51,7 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) { // What's my mangled name? CurrentFnName = Mang->getValueName(MF.getFunction()); + IncrementFunctionNumber(); } // EmitAlignment - Emit an alignment directive to the specified power of two. From lattner at cs.uiuc.edu Mon Nov 21 02:14:20 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 02:14:20 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Message-ID: <200511210814.CAA05592@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCAsmPrinter.cpp updated: 1.119 -> 1.120 --- Log message: Use the FunctionNumber provided by the AsmPrinter class --- Diffs of the changes: (+15 -19) PPCAsmPrinter.cpp | 34 +++++++++++++++------------------- 1 files changed, 15 insertions(+), 19 deletions(-) Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.119 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.120 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.119 Mon Nov 21 02:02:41 2005 +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Mon Nov 21 02:14:07 2005 @@ -44,15 +44,11 @@ Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed"); class PPCAsmPrinter : public AsmPrinter { - public: +public: std::set FnStubs, GVStubs, LinkOnceStubs; PPCAsmPrinter(std::ostream &O, TargetMachine &TM) - : AsmPrinter(O, TM), FunctionNumber(0) {} - - /// Unique incrementer for label values for referencing Global values. - /// - unsigned FunctionNumber; + : AsmPrinter(O, TM) {} virtual const char *getPassName() const { return "PowerPC Assembly Printer"; @@ -163,8 +159,8 @@ void printPICLabel(const MachineInstr *MI, unsigned OpNo, MVT::ValueType VT) { // FIXME: should probably be converted to cout.width and cout.fill - O << "\"L0000" << FunctionNumber << "$pb\"\n"; - O << "\"L0000" << FunctionNumber << "$pb\":"; + O << "\"L0000" << getFunctionNumber() << "$pb\"\n"; + O << "\"L0000" << getFunctionNumber() << "$pb\":"; } void printSymbolHi(const MachineInstr *MI, unsigned OpNo, MVT::ValueType VT) { @@ -174,7 +170,7 @@ O << "ha16("; printOp(MI->getOperand(OpNo)); if (PICEnabled) - O << "-\"L0000" << FunctionNumber << "$pb\")"; + O << "-\"L0000" << getFunctionNumber() << "$pb\")"; else O << ')'; } @@ -187,7 +183,7 @@ O << "lo16("; printOp(MI->getOperand(OpNo)); if (PICEnabled) - O << "-\"L0000" << FunctionNumber << "$pb\")"; + O << "-\"L0000" << getFunctionNumber() << "$pb\")"; else O << ')'; } @@ -301,13 +297,13 @@ case MachineOperand::MO_MachineBasicBlock: { MachineBasicBlock *MBBOp = MO.getMachineBasicBlock(); - O << PrivateGlobalPrefix << "BB" << FunctionNumber << "_" + O << PrivateGlobalPrefix << "BB" << getFunctionNumber() << "_" << MBBOp->getNumber() << "\t; " << MBBOp->getBasicBlock()->getName(); return; } case MachineOperand::MO_ConstantPoolIndex: - O << PrivateGlobalPrefix << "CPI" << FunctionNumber + O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << MO.getConstantPoolIndex(); return; @@ -396,7 +392,7 @@ if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3; EmitAlignment(Alignment); - O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i + O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n'; EmitGlobalConstant(CP[i]); } @@ -426,7 +422,7 @@ I != E; ++I) { // Print a label for the basic block. if (I != MF.begin()) { - O << PrivateGlobalPrefix << "BB" << FunctionNumber << '_' + O << PrivateGlobalPrefix << "BB" << getFunctionNumber() << '_' << I->getNumber() << ":\t"; if (!I->getBasicBlock()->getName().empty()) O << CommentString << " " << I->getBasicBlock()->getName(); @@ -439,7 +435,6 @@ printMachineInstruction(II); } } - ++FunctionNumber; // We didn't modify anything. return false; @@ -610,7 +605,8 @@ for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { // Print a label for the basic block. - O << PrivateGlobalPrefix << "BB" << FunctionNumber << '_' << I->getNumber() + O << PrivateGlobalPrefix << "BB" << getFunctionNumber() << '_' + << I->getNumber() << ":\t" << CommentString << I->getBasicBlock()->getName() << '\n'; for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); II != E; ++II) { @@ -619,7 +615,6 @@ printMachineInstruction(II); } } - ++FunctionNumber; O << "LT.." << CurrentFnName << ":\n" << "\t.long 0\n" @@ -669,14 +664,15 @@ if (GV->isExternal() && GV->use_begin() == GV->use_end()) continue; + IncrementFunctionNumber(); std::string Name = GV->getName(); - std::string Label = "LC.." + utostr(FunctionNumber++); + std::string Label = "LC.." + utostr(getFunctionNumber()); GVToLabelMap[GV] = Label; O << Label << ":\n" << "\t.tc " << Name << "[TC]," << Name; if (GV->isExternal()) O << "[RW]"; O << '\n'; - } + } AsmPrinter::doInitialization(M); return false; // success From lattner at cs.uiuc.edu Mon Nov 21 02:24:22 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 02:24:22 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h Message-ID: <200511210824.CAA05722@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: AsmPrinter.h updated: 1.19 -> 1.20 --- Log message: add two more config directives, add method for printing constant pool --- Diffs of the changes: (+20 -1) AsmPrinter.h | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletion(-) Index: llvm/include/llvm/CodeGen/AsmPrinter.h diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.19 llvm/include/llvm/CodeGen/AsmPrinter.h:1.20 --- llvm/include/llvm/CodeGen/AsmPrinter.h:1.19 Mon Nov 21 02:12:47 2005 +++ llvm/include/llvm/CodeGen/AsmPrinter.h Mon Nov 21 02:24:11 2005 @@ -85,6 +85,8 @@ const char *FunctionAddrPrefix; // Defaults to "" const char *FunctionAddrSuffix; // Defaults to "" + //===--- Data Emission Directives -------------------------------------===// + /// ZeroDirective - this should be set to the directive used to get some /// number of zero bytes emitted to the current section. Common cases are /// "\t.zero\t" and "\t.space\t". If this is set to null, the @@ -108,6 +110,8 @@ const char *Data32bitsDirective; // Defaults to "\t.long\t" const char *Data64bitsDirective; // Defaults to "\t.quad\t" + //===--- Alignment Information ----------------------------------------===// + /// AlignDirective - The directive used to emit round up to an alignment /// boundary. /// @@ -118,6 +122,17 @@ /// Otherwise, it emits ".align log2(N)", e.g. 3 to align to an 8 byte /// boundary. bool AlignmentIsInBytes; // Defaults to true + + //===--- Section Switching Directives ---------------------------------===// + + /// SwitchToSectionDirective - This is the directive used when we want to + /// emit a global to an arbitrary section. The section name is emited after + /// this. + const char *SwitchToSectionDirective; // Defaults to "\t.section\t" + + /// ConstantPoolSection - This is the section that we SwitchToSection right + /// before emitting the constant pool for a function. + const char *ConstantPoolSection; // Defaults to "\t.section .rodata\n" AsmPrinter(std::ostream &o, TargetMachine &tm) : FunctionNumber(0), O(o), TM(tm), @@ -136,7 +151,9 @@ Data32bitsDirective("\t.long\t"), Data64bitsDirective("\t.quad\t"), AlignDirective("\t.align\t"), - AlignmentIsInBytes(true) { + AlignmentIsInBytes(true), + SwitchToSectionDirective("\t.section\t"), + ConstantPoolSection("\t.section .rodata\n") { } /// SwitchSection - Switch to the specified section of the executable if we @@ -170,6 +187,8 @@ /// SetupMachineFunction - This should be called when a new MachineFunction /// is being processed from runOnMachineFunction. void SetupMachineFunction(MachineFunction &MF); + + void EmitConstantPool(MachineConstantPool *MCP); /// EmitAlignment - Emit an alignment directive to the specified power of /// two boundary. For example, if you pass in 3 here, you will get an 8 From lattner at cs.uiuc.edu Mon Nov 21 02:25:21 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 02:25:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp Message-ID: <200511210825.CAA05813@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: AsmPrinter.cpp updated: 1.28 -> 1.29 --- Log message: Allow target to customize directive used to switch to arbitrary section in SwitchSection, add generic constant pool emitter --- Diffs of the changes: (+28 -1) AsmPrinter.cpp | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/AsmPrinter.cpp diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.28 llvm/lib/CodeGen/AsmPrinter.cpp:1.29 --- llvm/lib/CodeGen/AsmPrinter.cpp:1.28 Mon Nov 21 02:13:27 2005 +++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Nov 21 02:25:09 2005 @@ -14,6 +14,7 @@ #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/Constants.h" #include "llvm/Module.h" +#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/MathExtras.h" #include "llvm/Target/TargetMachine.h" @@ -26,7 +27,7 @@ std::string NS; if (GV && GV->hasSection()) - NS = ".section " + GV->getSection(); + NS = SwitchToSectionDirective + GV->getSection(); else NS = NewSection; @@ -54,6 +55,32 @@ IncrementFunctionNumber(); } +/// EmitConstantPool - Print to the current output stream assembly +/// representations of the constants in the constant pool MCP. This is +/// used to print out constants which have been "spilled to memory" by +/// the code generator. +/// +void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) { + const std::vector &CP = MCP->getConstants(); + if (CP.empty()) return; + const TargetData &TD = TM.getTargetData(); + + SwitchSection(ConstantPoolSection, 0); + for (unsigned i = 0, e = CP.size(); i != e; ++i) { + // FIXME: force doubles to be naturally aligned. We should handle this + // more correctly in the future. + unsigned Alignment = TD.getTypeAlignmentShift(CP[i]->getType()); + if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3; + + EmitAlignment(Alignment); + O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i + << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n'; + EmitGlobalConstant(CP[i]); + } +} + + + // EmitAlignment - Emit an alignment directive to the specified power of two. void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const { if (GV && GV->getAlignment()) From lattner at cs.uiuc.edu Mon Nov 21 02:26:28 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 02:26:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Message-ID: <200511210826.CAA05933@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCAsmPrinter.cpp updated: 1.120 -> 1.121 --- Log message: Use generic constant pool emission code in the AsmPrinter class. --- Diffs of the changes: (+4 -30) PPCAsmPrinter.cpp | 34 ++++------------------------------ 1 files changed, 4 insertions(+), 30 deletions(-) Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.120 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.121 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.120 Mon Nov 21 02:14:07 2005 +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Mon Nov 21 02:26:15 2005 @@ -25,7 +25,6 @@ #include "llvm/Module.h" #include "llvm/Assembly/Writer.h" #include "llvm/CodeGen/AsmPrinter.h" -#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/ValueTypes.h" @@ -58,8 +57,6 @@ return static_cast(TM); } - void printConstantPool(MachineConstantPool *MCP); - unsigned enumRegToMachineReg(unsigned enumReg) { switch (enumReg) { default: assert(0 && "Unhandled register!"); break; @@ -212,6 +209,7 @@ ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. Data64bitsDirective = 0; // we can't emit a 64-bit unit AlignmentIsInBytes = false; // Alignment is by power of 2. + ConstantPoolSection = "\t.const\t"; } virtual const char *getPassName() const { @@ -237,6 +235,7 @@ ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. Data64bitsDirective = 0; // we can't emit a 64-bit unit AlignmentIsInBytes = false; // Alignment is by power of 2. + ConstantPoolSection = "\t.const\t"; } virtual const char *getPassName() const { @@ -373,31 +372,6 @@ return; } -/// printConstantPool - Print to the current output stream assembly -/// representations of the constants in the constant pool MCP. This is -/// used to print out constants which have been "spilled to memory" by -/// the code generator. -/// -void PPCAsmPrinter::printConstantPool(MachineConstantPool *MCP) { - const std::vector &CP = MCP->getConstants(); - const TargetData &TD = TM.getTargetData(); - - if (CP.empty()) return; - - SwitchSection(".const", 0); - for (unsigned i = 0, e = CP.size(); i != e; ++i) { - // FIXME: force doubles to be naturally aligned. We should handle this - // more correctly in the future. - unsigned Alignment = TD.getTypeAlignmentShift(CP[i]->getType()); - if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3; - - EmitAlignment(Alignment); - O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i - << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n'; - EmitGlobalConstant(CP[i]); - } -} - /// runOnMachineFunction - This uses the printMachineInstruction() /// method to print assembly for each instruction. @@ -407,7 +381,7 @@ O << "\n\n"; // Print out constants referenced by the function - printConstantPool(MF.getConstantPool()); + EmitConstantPool(MF.getConstantPool()); // Print out labels for the function. const Function *F = MF.getFunction(); @@ -588,7 +562,7 @@ SetupMachineFunction(MF); // Print out constants referenced by the function - printConstantPool(MF.getConstantPool()); + EmitConstantPool(MF.getConstantPool()); // Print out header for the function. O << "\t.csect .text[PR]\n" From lattner at cs.uiuc.edu Mon Nov 21 02:29:29 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 02:29:29 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Message-ID: <200511210829.CAA06065@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaAsmPrinter.cpp updated: 1.25 -> 1.26 --- Log message: Switch to using the generic constant pool emitter impl, use shorter CPI names --- Diffs of the changes: (+2 -25) AlphaAsmPrinter.cpp | 27 ++------------------------- 1 files changed, 2 insertions(+), 25 deletions(-) Index: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp diff -u llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.25 llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.26 --- llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.25 Mon Nov 21 01:51:23 2005 +++ llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Mon Nov 21 02:29:17 2005 @@ -18,7 +18,6 @@ #include "llvm/Module.h" #include "llvm/Type.h" #include "llvm/Assembly/Writer.h" -#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/Target/TargetMachine.h" @@ -55,7 +54,6 @@ } bool printInstruction(const MachineInstr *MI); void printOp(const MachineOperand &MO, bool IsCallOp = false); - void printConstantPool(MachineConstantPool *MCP); void printOperand(const MachineInstr *MI, int opNum, MVT::ValueType VT); void printBaseOffsetPair (const MachineInstr *MI, int i, bool brackets=true); void printMachineInstruction(const MachineInstr *MI); @@ -128,7 +126,7 @@ } case MachineOperand::MO_ConstantPoolIndex: - O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" + O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_" << MO.getConstantPoolIndex(); return; @@ -173,7 +171,7 @@ O << "\n\n"; // Print out constants referenced by the function - printConstantPool(MF.getConstantPool()); + EmitConstantPool(MF.getConstantPool()); // Print out labels for the function. SwitchSection("\t.section .text", MF.getFunction()); @@ -204,27 +202,6 @@ return false; } - -/// printConstantPool - Print to the current output stream assembly -/// representations of the constants in the constant pool MCP. This is -/// used to print out constants which have been "spilled to memory" by -/// the code generator. -/// -void AlphaAsmPrinter::printConstantPool(MachineConstantPool *MCP) { - const std::vector &CP = MCP->getConstants(); - const TargetData &TD = TM.getTargetData(); - - if (CP.empty()) return; - - SwitchSection("\t.section .rodata", 0); - for (unsigned i = 0, e = CP.size(); i != e; ++i) { - EmitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); - O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i - << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n"; - EmitGlobalConstant(CP[i]); - } -} - bool AlphaAsmPrinter::doInitialization(Module &M) { AsmPrinter::doInitialization(M); From lattner at cs.uiuc.edu Mon Nov 21 02:32:35 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 02:32:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86AsmPrinter.cpp X86AsmPrinter.h X86IntelAsmPrinter.cpp Message-ID: <200511210832.CAA06144@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ATTAsmPrinter.cpp updated: 1.12 -> 1.13 X86AsmPrinter.cpp updated: 1.150 -> 1.151 X86AsmPrinter.h updated: 1.4 -> 1.5 X86IntelAsmPrinter.cpp updated: 1.8 -> 1.9 --- Log message: Switch to using the shared constant pool printer, along with using shorter CPI ids --- Diffs of the changes: (+5 -31) X86ATTAsmPrinter.cpp | 4 ++-- X86AsmPrinter.cpp | 27 +-------------------------- X86AsmPrinter.h | 1 - X86IntelAsmPrinter.cpp | 4 ++-- 4 files changed, 5 insertions(+), 31 deletions(-) Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.12 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.13 --- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.12 Mon Nov 21 01:51:23 2005 +++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Mon Nov 21 02:32:23 2005 @@ -29,7 +29,7 @@ O << "\n\n"; // Print out constants referenced by the function - printConstantPool(MF.getConstantPool()); + EmitConstantPool(MF.getConstantPool()); // Print out labels for the function. SwitchSection("\t.text\n", MF.getFunction()); @@ -176,7 +176,7 @@ O << "]"; return; } else if (BaseReg.isConstantPoolIndex()) { - O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" + O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_" << BaseReg.getConstantPoolIndex(); if (DispSpec.getImmedValue()) O << "+" << DispSpec.getImmedValue(); Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.150 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.151 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.150 Mon Nov 21 01:51:23 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Mon Nov 21 02:32:23 2005 @@ -68,37 +68,12 @@ Data64bitsDirective = 0; // we can't emit a 64-bit unit ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. PrivateGlobalPrefix = "L"; // Marker for constant pool idxs + ConstantPoolSection = "\t.const\n"; } return AsmPrinter::doInitialization(M); } -/// printConstantPool - Print to the current output stream assembly -/// representations of the constants in the constant pool MCP. This is -/// used to print out constants which have been "spilled to memory" by -/// the code generator. -/// -void X86SharedAsmPrinter::printConstantPool(MachineConstantPool *MCP) { - const std::vector &CP = MCP->getConstants(); - const TargetData &TD = TM.getTargetData(); - - if (CP.empty()) return; - - SwitchSection(forDarwin ? "\t.const\n" : "\t.section .rodata\n", 0); - - for (unsigned i = 0, e = CP.size(); i != e; ++i) { - // FIXME: force doubles to be naturally aligned. We should handle this - // more correctly in the future. - if (CP[i]->getType() == Type::DoubleTy) - EmitAlignment(3); - else - EmitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); - O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i - << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n"; - EmitGlobalConstant(CP[i]); - } -} - bool X86SharedAsmPrinter::doFinalization(Module &M) { const TargetData &TD = TM.getTargetData(); Index: llvm/lib/Target/X86/X86AsmPrinter.h diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.4 llvm/lib/Target/X86/X86AsmPrinter.h:1.5 --- llvm/lib/Target/X86/X86AsmPrinter.h:1.4 Mon Nov 21 01:11:11 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.h Mon Nov 21 02:32:23 2005 @@ -32,7 +32,6 @@ : AsmPrinter(O, TM), forCygwin(false), forDarwin(false) { } bool doInitialization(Module &M); - void printConstantPool(MachineConstantPool *MCP); bool doFinalization(Module &M); bool forCygwin; Index: llvm/lib/Target/X86/X86IntelAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.8 llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.9 --- llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.8 Mon Nov 21 01:51:23 2005 +++ llvm/lib/Target/X86/X86IntelAsmPrinter.cpp Mon Nov 21 02:32:23 2005 @@ -29,7 +29,7 @@ O << "\n\n"; // Print out constants referenced by the function - printConstantPool(MF.getConstantPool()); + EmitConstantPool(MF.getConstantPool()); // Print out labels for the function. SwitchSection("\t.text\n", MF.getFunction()); @@ -143,7 +143,7 @@ O << "]"; return; } else if (BaseReg.isConstantPoolIndex()) { - O << "[" << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" + O << "[" << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_" << BaseReg.getConstantPoolIndex(); if (IndexReg.getReg()) { From lattner at cs.uiuc.edu Mon Nov 21 02:33:29 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 02:33:29 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86AsmPrinter.cpp Message-ID: <200511210833.CAA06179@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86AsmPrinter.cpp updated: 1.151 -> 1.152 --- Log message: prune #include --- Diffs of the changes: (+0 -1) X86AsmPrinter.cpp | 1 - 1 files changed, 1 deletion(-) Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.151 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.152 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.151 Mon Nov 21 02:32:23 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Mon Nov 21 02:33:17 2005 @@ -20,7 +20,6 @@ #include "llvm/Module.h" #include "llvm/Type.h" #include "llvm/Assembly/Writer.h" -#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/CommandLine.h" using namespace llvm; From lattner at cs.uiuc.edu Mon Nov 21 02:38:38 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 02:38:38 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64AsmPrinter.cpp Message-ID: <200511210838.CAA06308@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64AsmPrinter.cpp updated: 1.18 -> 1.19 --- Log message: Start using shared asmprinter Constant Pool emitter, use shorter cpi names. --- Diffs of the changes: (+5 -26) IA64AsmPrinter.cpp | 31 +++++-------------------------- 1 files changed, 5 insertions(+), 26 deletions(-) Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.18 llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.19 --- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.18 Mon Nov 21 01:51:23 2005 +++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Mon Nov 21 02:38:26 2005 @@ -22,7 +22,6 @@ #include "llvm/Type.h" #include "llvm/Assembly/Writer.h" #include "llvm/CodeGen/AsmPrinter.h" -#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/Target/TargetMachine.h" @@ -41,32 +40,10 @@ IA64SharedAsmPrinter(std::ostream &O, TargetMachine &TM) : AsmPrinter(O, TM) { } - void printConstantPool(MachineConstantPool *MCP); bool doFinalization(Module &M); }; } -/// printConstantPool - Print to the current output stream assembly -/// representations of the constants in the constant pool MCP. This is -/// used to print out constants which have been "spilled to memory" by -/// the code generator. -/// -void IA64SharedAsmPrinter::printConstantPool(MachineConstantPool *MCP) { - const std::vector &CP = MCP->getConstants(); - const TargetData &TD = TM.getTargetData(); - - if (CP.empty()) return; - - // FIXME: would be nice to have rodata (no 'w') when appropriate? - SwitchSection("\n\t.section .data, \"aw\", \"progbits\"\n", 0); - for (unsigned i = 0, e = CP.size(); i != e; ++i) { - EmitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); - O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i - << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n"; - EmitGlobalConstant(CP[i]); - } -} - bool IA64SharedAsmPrinter::doFinalization(Module &M) { const TargetData &TD = TM.getTargetData(); @@ -169,7 +146,9 @@ GlobalVarAddrSuffix=""; FunctionAddrPrefix="@fptr("; FunctionAddrSuffix=")"; - + + // FIXME: would be nice to have rodata (no 'w') when appropriate? + ConstantPoolSection = "\n\t.section .data, \"aw\", \"progbits\"\n"; } virtual const char *getPassName() const { @@ -264,7 +243,7 @@ O << "\n\n"; // Print out constants referenced by the function - printConstantPool(MF.getConstantPool()); + EmitConstantPool(MF.getConstantPool()); // Print out labels for the function. SwitchSection("\n\t.section .text, \"ax\", \"progbits\"\n", MF.getFunction()); @@ -328,7 +307,7 @@ return; case MachineOperand::MO_ConstantPoolIndex: { - O << "@gprel(" << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" + O << "@gprel(" << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_" << MO.getConstantPoolIndex() << ")"; return; } From lattner at cs.uiuc.edu Mon Nov 21 02:40:29 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 02:40:29 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64AsmPrinter.cpp Message-ID: <200511210840.CAA06382@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64AsmPrinter.cpp updated: 1.19 -> 1.20 --- Log message: Eliminate unneeded intermediate class. Move doFinalizeMethod to bottom of file. --- Diffs of the changes: (+88 -99) IA64AsmPrinter.cpp | 187 ++++++++++++++++++++++++----------------------------- 1 files changed, 88 insertions(+), 99 deletions(-) Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.19 llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.20 --- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.19 Mon Nov 21 02:38:26 2005 +++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Mon Nov 21 02:40:17 2005 @@ -33,107 +33,10 @@ namespace { Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed"); - struct IA64SharedAsmPrinter : public AsmPrinter { - + struct IA64AsmPrinter : public AsmPrinter { std::set ExternalFunctionNames, ExternalObjectNames; - IA64SharedAsmPrinter(std::ostream &O, TargetMachine &TM) - : AsmPrinter(O, TM) { } - - bool doFinalization(Module &M); - }; -} - -bool IA64SharedAsmPrinter::doFinalization(Module &M) { - const TargetData &TD = TM.getTargetData(); - - // Print out module-level global variables here. - for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); - I != E; ++I) - if (I->hasInitializer()) { // External global require no code - O << "\n\n"; - std::string name = Mang->getValueName(I); - Constant *C = I->getInitializer(); - unsigned Size = TD.getTypeSize(C->getType()); - unsigned Align = TD.getTypeAlignmentShift(C->getType()); - - if (C->isNullValue() && - (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || - I->hasWeakLinkage() /* FIXME: Verify correct */)) { - SwitchSection(".data", I); - if (I->hasInternalLinkage()) { - O << "\t.lcomm " << name << "," << TD.getTypeSize(C->getType()) - << "," << (1 << Align); - O << "\t\t// "; - } else { - O << "\t.common " << name << "," << TD.getTypeSize(C->getType()) - << "," << (1 << Align); - O << "\t\t// "; - } - WriteAsOperand(O, I, true, true, &M); - O << "\n"; - } else { - switch (I->getLinkage()) { - case GlobalValue::LinkOnceLinkage: - case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. - // Nonnull linkonce -> weak - O << "\t.weak " << name << "\n"; - O << "\t.section\t.llvm.linkonce.d." << name - << ", \"aw\", \"progbits\"\n"; - SwitchSection("", I); - break; - case GlobalValue::AppendingLinkage: - // FIXME: appending linkage variables should go into a section of - // their name or something. For now, just emit them as external. - case GlobalValue::ExternalLinkage: - // If external or appending, declare as a global symbol - O << "\t.global " << name << "\n"; - // FALL THROUGH - case GlobalValue::InternalLinkage: - SwitchSection(C->isNullValue() ? ".bss" : ".data", I); - break; - case GlobalValue::GhostLinkage: - std::cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n"; - abort(); - } - - EmitAlignment(Align); - O << "\t.type " << name << ", at object\n"; - O << "\t.size " << name << "," << Size << "\n"; - O << name << ":\t\t\t\t// "; - WriteAsOperand(O, I, true, true, &M); - O << " = "; - WriteAsOperand(O, C, false, false, &M); - O << "\n"; - EmitGlobalConstant(C); - } - } - - // we print out ".global X \n .type X, @function" for each external function - O << "\n\n// br.call targets referenced (and not defined) above: \n"; - for (std::set::iterator i = ExternalFunctionNames.begin(), - e = ExternalFunctionNames.end(); i!=e; ++i) { - O << "\t.global " << *i << "\n\t.type " << *i << ", @function\n"; - } - O << "\n\n"; - - // we print out ".global X \n .type X, @object" for each external object - O << "\n\n// (external) symbols referenced (and not defined) above: \n"; - for (std::set::iterator i = ExternalObjectNames.begin(), - e = ExternalObjectNames.end(); i!=e; ++i) { - O << "\t.global " << *i << "\n\t.type " << *i << ", @object\n"; - } - O << "\n\n"; - - AsmPrinter::doFinalization(M); - return false; // success -} - -namespace { - struct IA64AsmPrinter : public IA64SharedAsmPrinter { - IA64AsmPrinter(std::ostream &O, TargetMachine &TM) - : IA64SharedAsmPrinter(O, TM) { - + IA64AsmPrinter(std::ostream &O, TargetMachine &TM) : AsmPrinter(O, TM) { CommentString = "//"; Data8bitsDirective = "\tdata1\t"; // FIXME: check that we are Data16bitsDirective = "\tdata2.ua\t"; // disabling auto-alignment @@ -227,6 +130,7 @@ void printOp(const MachineOperand &MO, bool isBRCALLinsn= false); bool runOnMachineFunction(MachineFunction &F); bool doInitialization(Module &M); + bool doFinalization(Module &M); }; } // end of anonymous namespace @@ -379,6 +283,91 @@ return false; } +bool IA64AsmPrinter::doFinalization(Module &M) { + const TargetData &TD = TM.getTargetData(); + + // Print out module-level global variables here. + for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); + I != E; ++I) + if (I->hasInitializer()) { // External global require no code + O << "\n\n"; + std::string name = Mang->getValueName(I); + Constant *C = I->getInitializer(); + unsigned Size = TD.getTypeSize(C->getType()); + unsigned Align = TD.getTypeAlignmentShift(C->getType()); + + if (C->isNullValue() && + (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || + I->hasWeakLinkage() /* FIXME: Verify correct */)) { + SwitchSection(".data", I); + if (I->hasInternalLinkage()) { + O << "\t.lcomm " << name << "," << TD.getTypeSize(C->getType()) + << "," << (1 << Align); + O << "\t\t// "; + } else { + O << "\t.common " << name << "," << TD.getTypeSize(C->getType()) + << "," << (1 << Align); + O << "\t\t// "; + } + WriteAsOperand(O, I, true, true, &M); + O << "\n"; + } else { + switch (I->getLinkage()) { + case GlobalValue::LinkOnceLinkage: + case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. + // Nonnull linkonce -> weak + O << "\t.weak " << name << "\n"; + O << "\t.section\t.llvm.linkonce.d." << name + << ", \"aw\", \"progbits\"\n"; + SwitchSection("", I); + break; + case GlobalValue::AppendingLinkage: + // FIXME: appending linkage variables should go into a section of + // their name or something. For now, just emit them as external. + case GlobalValue::ExternalLinkage: + // If external or appending, declare as a global symbol + O << "\t.global " << name << "\n"; + // FALL THROUGH + case GlobalValue::InternalLinkage: + SwitchSection(C->isNullValue() ? ".bss" : ".data", I); + break; + case GlobalValue::GhostLinkage: + std::cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n"; + abort(); + } + + EmitAlignment(Align); + O << "\t.type " << name << ", at object\n"; + O << "\t.size " << name << "," << Size << "\n"; + O << name << ":\t\t\t\t// "; + WriteAsOperand(O, I, true, true, &M); + O << " = "; + WriteAsOperand(O, C, false, false, &M); + O << "\n"; + EmitGlobalConstant(C); + } + } + + // we print out ".global X \n .type X, @function" for each external function + O << "\n\n// br.call targets referenced (and not defined) above: \n"; + for (std::set::iterator i = ExternalFunctionNames.begin(), + e = ExternalFunctionNames.end(); i!=e; ++i) { + O << "\t.global " << *i << "\n\t.type " << *i << ", @function\n"; + } + O << "\n\n"; + + // we print out ".global X \n .type X, @object" for each external object + O << "\n\n// (external) symbols referenced (and not defined) above: \n"; + for (std::set::iterator i = ExternalObjectNames.begin(), + e = ExternalObjectNames.end(); i!=e; ++i) { + O << "\t.global " << *i << "\n\t.type " << *i << ", @object\n"; + } + O << "\n\n"; + + AsmPrinter::doFinalization(M); + return false; // success +} + /// createIA64CodePrinterPass - Returns a pass that prints the IA64 /// assembly code for a MachineFunction to the given output stream, using /// the given target machine description. From duraid at octopus.com.au Mon Nov 21 08:09:58 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Mon, 21 Nov 2005 08:09:58 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200511211409.IAA09165@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.115 -> 1.116 --- Log message: I think I know what you meant here, but just to be safe I'll let you do it. :) <_sabre_> excuses excuses --- Diffs of the changes: (+1 -1) RegAllocLinearScan.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.115 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.116 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.115 Mon Nov 21 01:06:27 2005 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Mon Nov 21 08:09:40 2005 @@ -547,7 +547,7 @@ minReg = reg; } } - assert(minReg && "Didn't find any reg!"); +// FIXME: assert(minReg && "Didn't find any reg!"); DEBUG(std::cerr << "\t\tregister with min weight: " << mri_->getName(minReg) << " (" << minWeight << ")\n"); From duraid at octopus.com.au Mon Nov 21 08:15:06 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Mon, 21 Nov 2005 08:15:06 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp Message-ID: <200511211415.IAA09368@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64ISelDAGToDAG.cpp updated: 1.10 -> 1.11 --- Log message: add support for div/rem to the dag->dag isel. yay. --- Diffs of the changes: (+180 -0) IA64ISelDAGToDAG.cpp | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 180 insertions(+) Index: llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp diff -u llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.10 llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.11 --- llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.10 Sun Nov 6 21:11:03 2005 +++ llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp Mon Nov 21 08:14:54 2005 @@ -93,6 +93,7 @@ #include "IA64GenDAGISel.inc" private: + SDOperand SelectDIV(SDOperand Op); SDOperand SelectCALL(SDOperand Op); }; } @@ -153,6 +154,179 @@ ScheduleAndEmitDAG(DAG); } +SDOperand IA64DAGToDAGISel::SelectDIV(SDOperand Op) { + SDNode *N = Op.Val; + SDOperand Chain = Select(N->getOperand(0)); + + SDOperand Tmp1 = Select(N->getOperand(0)); + SDOperand Tmp2 = Select(N->getOperand(1)); + + bool isFP=false; + + if(MVT::isFloatingPoint(Tmp1.getValueType())) + isFP=true; + + bool isModulus=false; // is it a division or a modulus? + bool isSigned=false; + + switch(N->getOpcode()) { + case ISD::FDIV: + case ISD::SDIV: isModulus=false; isSigned=true; break; + case ISD::UDIV: isModulus=false; isSigned=false; break; + case ISD::FREM: + case ISD::SREM: isModulus=true; isSigned=true; break; + case ISD::UREM: isModulus=true; isSigned=false; break; + } + + // TODO: check for integer divides by powers of 2 (or other simple patterns?) + + SDOperand TmpPR, TmpPR2; + SDOperand TmpF1, TmpF2, TmpF3, TmpF4, TmpF5, TmpF6, TmpF7, TmpF8; + SDOperand TmpF9, TmpF10,TmpF11,TmpF12,TmpF13,TmpF14,TmpF15; + SDOperand Result; + + // OK, emit some code: + + if(!isFP) { + // first, load the inputs into FP regs. + TmpF1 = CurDAG->getTargetNode(IA64::SETFSIG, MVT::f64, Tmp1); + Chain = TmpF1.getValue(1); + TmpF2 = CurDAG->getTargetNode(IA64::SETFSIG, MVT::f64, Tmp2); + Chain = TmpF2.getValue(1); + + // next, convert the inputs to FP + if(isSigned) { + TmpF3 = CurDAG->getTargetNode(IA64::FCVTXF, MVT::f64, TmpF1); + Chain = TmpF3.getValue(1); + TmpF4 = CurDAG->getTargetNode(IA64::FCVTXF, MVT::f64, TmpF2); + Chain = TmpF4.getValue(1); + } else { + TmpF3 = CurDAG->getTargetNode(IA64::FCVTXUFS1, MVT::f64, TmpF1); + Chain = TmpF3.getValue(1); + TmpF4 = CurDAG->getTargetNode(IA64::FCVTXUFS1, MVT::f64, TmpF2); + Chain = TmpF4.getValue(1); + } + + } else { // this is an FP divide/remainder, so we 'leak' some temp + // regs and assign TmpF3=Tmp1, TmpF4=Tmp2 + TmpF3=Tmp1; + TmpF4=Tmp2; + } + + // we start by computing an approximate reciprocal (good to 9 bits?) + // note, this instruction writes _both_ TmpF5 (answer) and TmpPR (predicate) + TmpF5 = CurDAG->getTargetNode(IA64::FRCPAS1, MVT::f64, MVT::i1, + TmpF3, TmpF4); + TmpPR = TmpF5.getValue(1); + Chain = TmpF5.getValue(2); + + if(!isModulus) { // if this is a divide, we worry about div-by-zero + SDOperand bogusPR = CurDAG->getTargetNode(IA64::CMPEQ, MVT::i1, + CurDAG->getRegister(IA64::r0, MVT::i64), + CurDAG->getRegister(IA64::r0, MVT::i64)); + Chain = bogusPR.getValue(1); + TmpPR2 = CurDAG->getTargetNode(IA64::TPCMPNE, MVT::i1, bogusPR, + CurDAG->getRegister(IA64::r0, MVT::i64), + CurDAG->getRegister(IA64::r0, MVT::i64), TmpPR); + Chain = TmpPR2.getValue(1); + } + + SDOperand F0 = CurDAG->getRegister(IA64::F0, MVT::f64); + SDOperand F1 = CurDAG->getRegister(IA64::F1, MVT::f64); + + // now we apply newton's method, thrice! (FIXME: this is ~72 bits of + // precision, don't need this much for f32/i32) + TmpF6 = CurDAG->getTargetNode(IA64::CFNMAS1, MVT::f64, + TmpF4, TmpF5, F1, TmpPR); + Chain = TmpF6.getValue(1); + TmpF7 = CurDAG->getTargetNode(IA64::CFMAS1, MVT::f64, + TmpF3, TmpF5, F0, TmpPR); + Chain = TmpF7.getValue(1); + TmpF8 = CurDAG->getTargetNode(IA64::CFMAS1, MVT::f64, + TmpF6, TmpF6, F0, TmpPR); + Chain = TmpF8.getValue(1); + TmpF9 = CurDAG->getTargetNode(IA64::CFMAS1, MVT::f64, + TmpF6, TmpF7, TmpF7, TmpPR); + Chain = TmpF9.getValue(1); + TmpF10 = CurDAG->getTargetNode(IA64::CFMAS1, MVT::f64, + TmpF6, TmpF5, TmpF5, TmpPR); + Chain = TmpF10.getValue(1); + TmpF11 = CurDAG->getTargetNode(IA64::CFMAS1, MVT::f64, + TmpF8, TmpF9, TmpF9, TmpPR); + Chain = TmpF11.getValue(1); + TmpF12 = CurDAG->getTargetNode(IA64::CFMAS1, MVT::f64, + TmpF8, TmpF10, TmpF10, TmpPR); + Chain = TmpF12.getValue(1); + TmpF13 = CurDAG->getTargetNode(IA64::CFNMAS1, MVT::f64, + TmpF4, TmpF11, TmpF3, TmpPR); + Chain = TmpF13.getValue(1); + + // FIXME: this is unfortunate :( + // the story is that the dest reg of the fnma above and the fma below + // (and therefore possibly the src of the fcvt.fx[u] as well) cannot + // be the same register, or this code breaks if the first argument is + // zero. (e.g. without this hack, 0%8 yields -64, not 0.) + TmpF14 = CurDAG->getTargetNode(IA64::CFMAS1, MVT::f64, + TmpF13, TmpF12, TmpF11, TmpPR); + Chain = TmpF14.getValue(1); + + if(isModulus) { // XXX: fragile! fixes _only_ mod, *breaks* div! ! + SDOperand bogus = CurDAG->getTargetNode(IA64::IUSE, MVT::Other, TmpF13); // hack :( + Chain = bogus.getValue(0); // hmmm + } + + if(!isFP) { + // round to an integer + if(isSigned) { + TmpF15 = CurDAG->getTargetNode(IA64::FCVTFXTRUNCS1, MVT::i64, TmpF14); + Chain = TmpF15.getValue(1); + } + else { + TmpF15 = CurDAG->getTargetNode(IA64::FCVTFXUTRUNCS1, MVT::i64, TmpF14); + Chain = TmpF15.getValue(1); + } + } else { + TmpF15 = TmpF14; + // EXERCISE: can you see why TmpF15=TmpF14 does not work here, and + // we really do need the above FMOV? ;) + } + + if(!isModulus) { + if(isFP) { // extra worrying about div-by-zero + // we do a 'conditional fmov' (of the correct result, depending + // on how the frcpa predicate turned out) + SDOperand bogoResult = CurDAG->getTargetNode(IA64::PFMOV, MVT::f64, + TmpF12, TmpPR2); + Chain = bogoResult.getValue(1); + Result = CurDAG->getTargetNode(IA64::CFMOV, MVT::f64, bogoResult, + TmpF15, TmpPR); + Chain = Result.getValue(1); + } + else { + Result = CurDAG->getTargetNode(IA64::GETFSIG, MVT::i64, TmpF15); + Chain = Result.getValue(1); + } + } else { // this is a modulus + if(!isFP) { + // answer = q * (-b) + a + SDOperand TmpI = CurDAG->getTargetNode(IA64::SUB, MVT::i64, + CurDAG->getRegister(IA64::r0, MVT::i64), Tmp2); + Chain = TmpI.getValue(1); + SDOperand TmpF = CurDAG->getTargetNode(IA64::SETFSIG, MVT::f64, TmpI); + Chain = TmpF.getValue(1); + SDOperand ModulusResult = CurDAG->getTargetNode(IA64::XMAL, MVT::f64, + TmpF15, TmpF, TmpF1); + Chain = ModulusResult.getValue(1); + Result = CurDAG->getTargetNode(IA64::GETFSIG, MVT::i64, ModulusResult); + Chain = Result.getValue(1); + } else { // FP modulus! The horror... the horror.... + assert(0 && "sorry, no FP modulus just yet!\n!\n"); + } + } + + return Result; +} + SDOperand IA64DAGToDAGISel::SelectCALL(SDOperand Op) { SDNode *N = Op.Val; @@ -355,6 +529,12 @@ case ISD::CALL: case ISD::TAILCALL: return SelectCALL(Op); + + case ISD::FDIV: + case ISD::SDIV: + case ISD::UDIV: + case ISD::SREM: + case ISD::UREM: return SelectDIV(Op); /* todo: * case ISD::DYNAMIC_STACKALLOC: From sabre at nondot.org Mon Nov 21 12:36:18 2005 From: sabre at nondot.org (Chris Lattner) Date: Mon, 21 Nov 2005 12:36:18 -0600 (CST) Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp In-Reply-To: <200511211409.IAA09165@zion.cs.uiuc.edu> References: <200511211409.IAA09165@zion.cs.uiuc.edu> Message-ID: > > I think I know what you meant here, but just to be safe I'll let you > do it. :) Can you send me a testcase that this assert breaks? Thanks, -Chris > --- > Diffs of the changes: (+1 -1) > > RegAllocLinearScan.cpp | 2 +- > 1 files changed, 1 insertion(+), 1 deletion(-) > > > Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp > diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.115 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.116 > --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.115 Mon Nov 21 01:06:27 2005 > +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Mon Nov 21 08:09:40 2005 > @@ -547,7 +547,7 @@ > minReg = reg; > } > } > - assert(minReg && "Didn't find any reg!"); > +// FIXME: assert(minReg && "Didn't find any reg!"); > DEBUG(std::cerr << "\t\tregister with min weight: " > << mri_->getName(minReg) << " (" << minWeight << ")\n"); > > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -Chris -- http://nondot.org/sabre/ http://llvm.org/ From lattner at cs.uiuc.edu Mon Nov 21 13:50:43 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 13:50:43 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86AsmPrinter.cpp Message-ID: <200511211950.NAA20142@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86AsmPrinter.cpp updated: 1.152 -> 1.153 --- Log message: simplify and genericize this code --- Diffs of the changes: (+69 -55) X86AsmPrinter.cpp | 124 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 69 insertions(+), 55 deletions(-) Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.152 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.153 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.152 Mon Nov 21 02:33:17 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Mon Nov 21 13:50:31 2005 @@ -40,8 +40,9 @@ /// doInitialization bool X86SharedAsmPrinter::doInitialization(Module& M) { - bool leadingUnderscore = false; forCygwin = false; + forDarwin = false; + bool forWin32 = false; const std::string& TT = M.getTargetTriple(); if (TT.length() > 5) { forCygwin = TT.find("cygwin") != std::string::npos || @@ -53,23 +54,26 @@ #elif defined(__APPLE__) forDarwin = true; #elif defined(_WIN32) - leadingUnderscore = true; -#else - leadingUnderscore = false; + forWin32 = true; #endif } - if (leadingUnderscore || forCygwin || forDarwin) - GlobalPrefix = "_"; - if (forDarwin) { AlignmentIsInBytes = false; + GlobalPrefix = "_"; Data64bitsDirective = 0; // we can't emit a 64-bit unit ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. PrivateGlobalPrefix = "L"; // Marker for constant pool idxs ConstantPoolSection = "\t.const\n"; - } - + LCOMMDirective = "\t.lcomm\t"; + COMMDirectiveTakesAlignment = false; + } else if (forCygwin) { + GlobalPrefix = "_"; + COMMDirectiveTakesAlignment = false; + } else if (forWin32) { + GlobalPrefix = "_"; + } + return AsmPrinter::doInitialization(M); } @@ -86,55 +90,65 @@ unsigned Size = TD.getTypeSize(C->getType()); unsigned Align = TD.getTypeAlignmentShift(C->getType()); - if (C->isNullValue() && - (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || - I->hasWeakLinkage() /* FIXME: Verify correct */)) { - SwitchSection(".data", I); - if (!forCygwin && !forDarwin && I->hasInternalLinkage()) - O << "\t.local " << name << "\n"; - if (forDarwin && I->hasInternalLinkage()) - O << "\t.lcomm " << name << "," << Size << "," << Align; - else - O << "\t.comm " << name << "," << Size; - if (!forCygwin && !forDarwin) - O << "," << (1 << Align); - O << "\t\t# "; - WriteAsOperand(O, I, true, true, &M); - O << "\n"; - } else { - switch (I->getLinkage()) { - default: assert(0 && "Unknown linkage type!"); - case GlobalValue::LinkOnceLinkage: - case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. - // Nonnull linkonce -> weak - O << "\t.weak " << name << "\n"; - O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\", at progbits\n"; - SwitchSection("", I); - break; - case GlobalValue::AppendingLinkage: - // FIXME: appending linkage variables should go into a section of - // their name or something. For now, just emit them as external. - case GlobalValue::ExternalLinkage: - // If external or appending, declare as a global symbol - O << "\t.globl " << name << "\n"; - // FALL THROUGH - case GlobalValue::InternalLinkage: - SwitchSection(C->isNullValue() ? ".bss" : ".data", I); - break; + switch (I->getLinkage()) { + default: assert(0 && "Unknown linkage type!"); + case GlobalValue::LinkOnceLinkage: + case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. + if (C->isNullValue()) { + O << COMMDirective << name << "," << Size; + if (COMMDirectiveTakesAlignment) + O << "," << (1 << Align); + O << "\t\t# "; + WriteAsOperand(O, I, true, true, &M); + O << "\n"; + continue; } - - EmitAlignment(Align); - if (!forCygwin && !forDarwin) { - O << "\t.type " << name << ", at object\n"; - O << "\t.size " << name << "," << Size << "\n"; + + // Nonnull linkonce -> weak + O << "\t.weak " << name << "\n"; + O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\", at progbits\n"; + SwitchSection("", I); + break; + case GlobalValue::InternalLinkage: + if (C->isNullValue()) { + if (LCOMMDirective) { + O << LCOMMDirective << name << "," << Size << "," << Align; + continue; + } else { + SwitchSection(".bss", I); + O << "\t.local " << name << "\n"; + O << COMMDirective << name << "," << Size; + if (COMMDirectiveTakesAlignment) + O << "," << (1 << Align); + O << "\t\t# "; + WriteAsOperand(O, I, true, true, &M); + O << "\n"; + continue; + } } - O << name << ":\t\t\t\t# "; - WriteAsOperand(O, I, true, true, &M); - O << " = "; - WriteAsOperand(O, C, false, false, &M); - O << "\n"; - EmitGlobalConstant(C); + SwitchSection(C->isNullValue() ? ".bss" : ".data", I); + break; + case GlobalValue::AppendingLinkage: + // FIXME: appending linkage variables should go into a section of + // their name or something. For now, just emit them as external. + case GlobalValue::ExternalLinkage: + SwitchSection(C->isNullValue() ? ".bss" : ".data", I); + // If external or appending, declare as a global symbol + O << "\t.globl " << name << "\n"; + break; + } + + EmitAlignment(Align); + if (!forCygwin && !forDarwin) { + O << "\t.type " << name << ", at object\n"; + O << "\t.size " << name << "," << Size << "\n"; } + O << name << ":\t\t\t\t# "; + WriteAsOperand(O, I, true, true, &M); + O << " = "; + WriteAsOperand(O, C, false, false, &M); + O << "\n"; + EmitGlobalConstant(C); } if (forDarwin) { From lattner at cs.uiuc.edu Mon Nov 21 13:52:03 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 13:52:03 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h Message-ID: <200511211952.NAA20652@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: AsmPrinter.h updated: 1.20 -> 1.21 --- Log message: Add some more directives --- Diffs of the changes: (+18 -1) AsmPrinter.h | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletion(-) Index: llvm/include/llvm/CodeGen/AsmPrinter.h diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.20 llvm/include/llvm/CodeGen/AsmPrinter.h:1.21 --- llvm/include/llvm/CodeGen/AsmPrinter.h:1.20 Mon Nov 21 02:24:11 2005 +++ llvm/include/llvm/CodeGen/AsmPrinter.h Mon Nov 21 13:51:51 2005 @@ -134,6 +134,20 @@ /// before emitting the constant pool for a function. const char *ConstantPoolSection; // Defaults to "\t.section .rodata\n" + //===--- Global Variable Emission Directives --------------------------===// + + /// LCOMMDirective - This is the name of a directive (if supported) that can + /// be used to efficiently declare a local (internal) block of zero + /// initialized data in the .bss/.data section. The syntax expected is: + /// SYMBOLNAME LENGTHINBYTES, ALIGNMENT + const char *LCOMMDirective; // Defaults to null. + + const char *COMMDirective; // Defaults to "\t.comm\t". + + /// COMMDirectiveTakesAlignment - True if COMMDirective take a third + /// argument that specifies the alignment of the declaration. + bool COMMDirectiveTakesAlignment; // Defaults to true. + AsmPrinter(std::ostream &o, TargetMachine &tm) : FunctionNumber(0), O(o), TM(tm), CommentString("#"), @@ -153,7 +167,10 @@ AlignDirective("\t.align\t"), AlignmentIsInBytes(true), SwitchToSectionDirective("\t.section\t"), - ConstantPoolSection("\t.section .rodata\n") { + ConstantPoolSection("\t.section .rodata\n"), + LCOMMDirective(0), + COMMDirective("\t.comm\t"), + COMMDirectiveTakesAlignment(true) { } /// SwitchSection - Switch to the specified section of the executable if we From lattner at cs.uiuc.edu Mon Nov 21 16:20:00 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 16:20:00 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86AsmPrinter.cpp X86AsmPrinter.h X86IntelAsmPrinter.cpp Message-ID: <200511212220.QAA29601@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ATTAsmPrinter.cpp updated: 1.13 -> 1.14 X86AsmPrinter.cpp updated: 1.153 -> 1.154 X86AsmPrinter.h updated: 1.5 -> 1.6 X86IntelAsmPrinter.cpp updated: 1.9 -> 1.10 --- Log message: Add a forELF flag, allowing the removal of forCygwin and simplification of conditionals. --- Diffs of the changes: (+12 -7) X86ATTAsmPrinter.cpp | 2 +- X86AsmPrinter.cpp | 11 ++++++++--- X86AsmPrinter.h | 4 ++-- X86IntelAsmPrinter.cpp | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.13 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.14 --- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.13 Mon Nov 21 02:32:23 2005 +++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Mon Nov 21 16:19:48 2005 @@ -35,7 +35,7 @@ SwitchSection("\t.text\n", MF.getFunction()); EmitAlignment(4); // FIXME: This should be parameterized somewhere. O << "\t.globl\t" << CurrentFnName << "\n"; - if (!forCygwin && !forDarwin) + if (forELF) O << "\t.type\t" << CurrentFnName << ", @function\n"; O << CurrentFnName << ":\n"; Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.153 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.154 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.153 Mon Nov 21 13:50:31 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Mon Nov 21 16:19:48 2005 @@ -39,15 +39,18 @@ cl::init(att)); /// doInitialization -bool X86SharedAsmPrinter::doInitialization(Module& M) { - forCygwin = false; +bool X86SharedAsmPrinter::doInitialization(Module &M) { + bool forCygwin = false; forDarwin = false; + forELF = false; bool forWin32 = false; const std::string& TT = M.getTargetTriple(); if (TT.length() > 5) { forCygwin = TT.find("cygwin") != std::string::npos || TT.find("mingw") != std::string::npos; forDarwin = TT.find("darwin") != std::string::npos; + if (!forDarwin && !forCygwin) + forELF = true; } else if (TT.empty()) { #if defined(__CYGWIN__) || defined(__MINGW32__) forCygwin = true; @@ -55,6 +58,8 @@ forDarwin = true; #elif defined(_WIN32) forWin32 = true; +#else + forELF = true; #endif } @@ -139,7 +144,7 @@ } EmitAlignment(Align); - if (!forCygwin && !forDarwin) { + if (forELF) { O << "\t.type " << name << ", at object\n"; O << "\t.size " << name << "," << Size << "\n"; } Index: llvm/lib/Target/X86/X86AsmPrinter.h diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.5 llvm/lib/Target/X86/X86AsmPrinter.h:1.6 --- llvm/lib/Target/X86/X86AsmPrinter.h:1.5 Mon Nov 21 02:32:23 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.h Mon Nov 21 16:19:48 2005 @@ -29,12 +29,12 @@ struct X86SharedAsmPrinter : public AsmPrinter { X86SharedAsmPrinter(std::ostream &O, TargetMachine &TM) - : AsmPrinter(O, TM), forCygwin(false), forDarwin(false) { } + : AsmPrinter(O, TM), forELF(false), forDarwin(false) { } bool doInitialization(Module &M); bool doFinalization(Module &M); - bool forCygwin; + bool forELF; bool forDarwin; // Necessary for Darwin to print out the apprioriate types of linker stubs Index: llvm/lib/Target/X86/X86IntelAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.9 llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.10 --- llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.9 Mon Nov 21 02:32:23 2005 +++ llvm/lib/Target/X86/X86IntelAsmPrinter.cpp Mon Nov 21 16:19:48 2005 @@ -35,7 +35,7 @@ SwitchSection("\t.text\n", MF.getFunction()); EmitAlignment(4); O << "\t.globl\t" << CurrentFnName << "\n"; - if (!forCygwin && !forDarwin) + if (forELF) O << "\t.type\t" << CurrentFnName << ", @function\n"; O << CurrentFnName << ":\n"; From dhurjati at cs.uiuc.edu Mon Nov 21 16:26:38 2005 From: dhurjati at cs.uiuc.edu (Dinakar Dhurjati) Date: Mon, 21 Nov 2005 16:26:38 -0600 Subject: [llvm-commits] CVS: llvm-www/pubs/2005-11-SAFECodeTR.pdf Message-ID: <200511212226.QAA29701@zion.cs.uiuc.edu> Changes in directory llvm-www/pubs: 2005-11-SAFECodeTR.pdf updated: 1.4 -> 1.5 --- Log message: safecode techreport fixes --- Diffs of the changes: (+0 -0) 2005-11-SAFECodeTR.pdf | 0 1 files changed Index: llvm-www/pubs/2005-11-SAFECodeTR.pdf From lattner at cs.uiuc.edu Mon Nov 21 16:32:10 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 16:32:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86Subtarget.cpp X86Subtarget.h Message-ID: <200511212232.QAA29847@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86Subtarget.cpp updated: 1.6 -> 1.7 X86Subtarget.h updated: 1.5 -> 1.6 --- Log message: Make the X86 subtarget compute the basic target type: ELF, Cygwin, Darwin, or native Win32 --- Diffs of the changes: (+24 -15) X86Subtarget.cpp | 35 ++++++++++++++++++++--------------- X86Subtarget.h | 4 ++++ 2 files changed, 24 insertions(+), 15 deletions(-) Index: llvm/lib/Target/X86/X86Subtarget.cpp diff -u llvm/lib/Target/X86/X86Subtarget.cpp:1.6 llvm/lib/Target/X86/X86Subtarget.cpp:1.7 --- llvm/lib/Target/X86/X86Subtarget.cpp:1.6 Thu Sep 1 16:38:21 2005 +++ llvm/lib/Target/X86/X86Subtarget.cpp Mon Nov 21 16:31:58 2005 @@ -21,37 +21,42 @@ asmLeadingUnderscore(false), asmAlignmentIsInBytes(false), asmPrintDotLocalConstants(false), asmPrintDotLCommConstants(false), asmPrintConstantAlignment(false) { - // Declare a boolean for each major platform. - bool forCygwin = false; - bool forDarwin = false; - bool forWindows = false; - + + // Default to ELF unless otherwise specified. + TargetType = isELF; + // Set the boolean corresponding to the current target triple, or the default // if one cannot be determined, to true. const std::string& TT = M.getTargetTriple(); if (TT.length() > 5) { - forCygwin = TT.find("cygwin") != std::string::npos || - TT.find("mingw") != std::string::npos; - forDarwin = TT.find("darwin") != std::string::npos; - forWindows = TT.find("win32") != std::string::npos; + if (TT.find("cygwin") != std::string::npos || + TT.find("mingw") != std::string::npos) + TargetType = isCygwin; + else if (TT.find("darwin") != std::string::npos) + TargetType = isDarwin; + else if (TT.find("win32") != std::string::npos) + TargetType = isWindows; } else if (TT.empty()) { #if defined(__CYGWIN__) || defined(__MINGW32__) - forCygwin = true; + TargetType = isCygwin; #elif defined(__APPLE__) - forDarwin = true; + TargetType = isDarwin; #elif defined(_WIN32) - forWindows = true; + TargetType = isWindows; #endif } - if (forCygwin) { + switch (TargetType) { + case isCygwin: asmLeadingUnderscore = true; - } else if (forDarwin) { + break; + case isDarwin: stackAlignment = 16; indirectExternAndWeakGlobals = true; asmDarwinLinkerStubs = true; asmLeadingUnderscore = true; asmPrintDotLCommConstants = true; - } else if (forWindows) { + break; + default: break; } } Index: llvm/lib/Target/X86/X86Subtarget.h diff -u llvm/lib/Target/X86/X86Subtarget.h:1.5 llvm/lib/Target/X86/X86Subtarget.h:1.6 --- llvm/lib/Target/X86/X86Subtarget.h:1.5 Thu Sep 1 16:38:21 2005 +++ llvm/lib/Target/X86/X86Subtarget.h Mon Nov 21 16:31:58 2005 @@ -38,6 +38,10 @@ bool asmPrintDotLCommConstants; bool asmPrintConstantAlignment; public: + enum { + isELF, isCygwin, isDarwin, isWindows + } TargetType; + /// This constructor initializes the data members to match that /// of the specified module. /// From dhurjati at cs.uiuc.edu Mon Nov 21 16:35:32 2005 From: dhurjati at cs.uiuc.edu (Dinakar Dhurjati) Date: Mon, 21 Nov 2005 16:35:32 -0600 Subject: [llvm-commits] CVS: llvm-www/pubs/2005-11-SAFECodeTR.pdf Message-ID: <200511212235.QAA29902@zion.cs.uiuc.edu> Changes in directory llvm-www/pubs: 2005-11-SAFECodeTR.pdf updated: 1.5 -> 1.6 --- Log message: safecode techreport fixes --- Diffs of the changes: (+0 -0) 2005-11-SAFECodeTR.pdf | 0 1 files changed Index: llvm-www/pubs/2005-11-SAFECodeTR.pdf From lattner at cs.uiuc.edu Mon Nov 21 16:39:52 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 16:39:52 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86AsmPrinter.cpp X86AsmPrinter.h Message-ID: <200511212239.QAA29983@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ATTAsmPrinter.cpp updated: 1.14 -> 1.15 X86AsmPrinter.cpp updated: 1.154 -> 1.155 X86AsmPrinter.h updated: 1.6 -> 1.7 --- Log message: Use subtarget information computed by X86Subtarget instead of rolling our own. --- Diffs of the changes: (+22 -29) X86ATTAsmPrinter.cpp | 2 +- X86AsmPrinter.cpp | 47 ++++++++++++++++++++--------------------------- X86AsmPrinter.h | 2 +- 3 files changed, 22 insertions(+), 29 deletions(-) Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.14 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.15 --- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.14 Mon Nov 21 16:19:48 2005 +++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Mon Nov 21 16:39:40 2005 @@ -54,7 +54,7 @@ printMachineInstruction(II); } } - if (!forDarwin) + if (forELF) O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n"; // We didn't modify anything. Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.154 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.155 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.154 Mon Nov 21 16:19:48 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Mon Nov 21 16:39:40 2005 @@ -16,6 +16,7 @@ #include "X86ATTAsmPrinter.h" #include "X86IntelAsmPrinter.h" +#include "X86Subtarget.h" #include "X86.h" #include "llvm/Module.h" #include "llvm/Type.h" @@ -40,30 +41,16 @@ /// doInitialization bool X86SharedAsmPrinter::doInitialization(Module &M) { - bool forCygwin = false; + const X86Subtarget *Subtarget = &TM.getSubtarget(); + + forELF = false; forDarwin = false; - forELF = false; - bool forWin32 = false; - const std::string& TT = M.getTargetTriple(); - if (TT.length() > 5) { - forCygwin = TT.find("cygwin") != std::string::npos || - TT.find("mingw") != std::string::npos; - forDarwin = TT.find("darwin") != std::string::npos; - if (!forDarwin && !forCygwin) - forELF = true; - } else if (TT.empty()) { -#if defined(__CYGWIN__) || defined(__MINGW32__) - forCygwin = true; -#elif defined(__APPLE__) - forDarwin = true; -#elif defined(_WIN32) - forWin32 = true; -#else + + switch (Subtarget->TargetType) { + case X86Subtarget::isELF: forELF = true; -#endif - } - - if (forDarwin) { + break; + case X86Subtarget::isDarwin: AlignmentIsInBytes = false; GlobalPrefix = "_"; Data64bitsDirective = 0; // we can't emit a 64-bit unit @@ -72,12 +59,17 @@ ConstantPoolSection = "\t.const\n"; LCOMMDirective = "\t.lcomm\t"; COMMDirectiveTakesAlignment = false; - } else if (forCygwin) { + forDarwin = true; + break; + case X86Subtarget::isCygwin: GlobalPrefix = "_"; COMMDirectiveTakesAlignment = false; - } else if (forWin32) { + break; + case X86Subtarget::isWindows: GlobalPrefix = "_"; - } + break; + default: break; + } return AsmPrinter::doInitialization(M); } @@ -87,7 +79,7 @@ // Print out module-level global variables here. for (Module::const_global_iterator I = M.global_begin(), - E = M.global_end(); I != E; ++I) + E = M.global_end(); I != E; ++I) { if (I->hasInitializer()) { // External global require no code O << "\n\n"; std::string name = Mang->getValueName(I); @@ -155,7 +147,8 @@ O << "\n"; EmitGlobalConstant(C); } - + } + if (forDarwin) { SwitchSection("", 0); // Output stubs for external global variables Index: llvm/lib/Target/X86/X86AsmPrinter.h diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.6 llvm/lib/Target/X86/X86AsmPrinter.h:1.7 --- llvm/lib/Target/X86/X86AsmPrinter.h:1.6 Mon Nov 21 16:19:48 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.h Mon Nov 21 16:39:40 2005 @@ -35,7 +35,7 @@ bool doFinalization(Module &M); bool forELF; - bool forDarwin; + bool forDarwin; // FIXME: eliminate. // Necessary for Darwin to print out the apprioriate types of linker stubs std::set FnStubs, GVStubs, LinkOnceStubs; From lattner at cs.uiuc.edu Mon Nov 21 16:44:10 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 16:44:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86Subtarget.cpp X86Subtarget.h Message-ID: <200511212244.QAA30081@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86Subtarget.cpp updated: 1.7 -> 1.8 X86Subtarget.h updated: 1.6 -> 1.7 --- Log message: Simplify the subtarget info, allow the asmwriter to do some target sensing based on TargetType. --- Diffs of the changes: (+2 -22) X86Subtarget.cpp | 17 ++--------------- X86Subtarget.h | 7 ------- 2 files changed, 2 insertions(+), 22 deletions(-) Index: llvm/lib/Target/X86/X86Subtarget.cpp diff -u llvm/lib/Target/X86/X86Subtarget.cpp:1.7 llvm/lib/Target/X86/X86Subtarget.cpp:1.8 --- llvm/lib/Target/X86/X86Subtarget.cpp:1.7 Mon Nov 21 16:31:58 2005 +++ llvm/lib/Target/X86/X86Subtarget.cpp Mon Nov 21 16:43:58 2005 @@ -16,11 +16,7 @@ using namespace llvm; X86Subtarget::X86Subtarget(const Module &M, const std::string &FS) - : TargetSubtarget(), stackAlignment(8), - indirectExternAndWeakGlobals(false), asmDarwinLinkerStubs(false), - asmLeadingUnderscore(false), asmAlignmentIsInBytes(false), - asmPrintDotLocalConstants(false), asmPrintDotLCommConstants(false), - asmPrintConstantAlignment(false) { + : stackAlignment(8), indirectExternAndWeakGlobals(false) { // Default to ELF unless otherwise specified. TargetType = isELF; @@ -46,17 +42,8 @@ #endif } - switch (TargetType) { - case isCygwin: - asmLeadingUnderscore = true; - break; - case isDarwin: + if (TargetType == isDarwin) { stackAlignment = 16; indirectExternAndWeakGlobals = true; - asmDarwinLinkerStubs = true; - asmLeadingUnderscore = true; - asmPrintDotLCommConstants = true; - break; - default: break; } } Index: llvm/lib/Target/X86/X86Subtarget.h diff -u llvm/lib/Target/X86/X86Subtarget.h:1.6 llvm/lib/Target/X86/X86Subtarget.h:1.7 --- llvm/lib/Target/X86/X86Subtarget.h:1.6 Mon Nov 21 16:31:58 2005 +++ llvm/lib/Target/X86/X86Subtarget.h Mon Nov 21 16:43:58 2005 @@ -30,13 +30,6 @@ /// Used by instruction selector bool indirectExternAndWeakGlobals; - /// Used by the asm printer - bool asmDarwinLinkerStubs; - bool asmLeadingUnderscore; - bool asmAlignmentIsInBytes; - bool asmPrintDotLocalConstants; - bool asmPrintDotLCommConstants; - bool asmPrintConstantAlignment; public: enum { isELF, isCygwin, isDarwin, isWindows From lattner at cs.uiuc.edu Mon Nov 21 16:48:31 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 16:48:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86AsmPrinter.cpp Message-ID: <200511212248.QAA30235@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86AsmPrinter.cpp updated: 1.155 -> 1.156 --- Log message: Remove a level of indentation by using a continue. --- Diffs of the changes: (+56 -56) X86AsmPrinter.cpp | 112 +++++++++++++++++++++++++++--------------------------- 1 files changed, 56 insertions(+), 56 deletions(-) Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.155 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.156 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.155 Mon Nov 21 16:39:40 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Mon Nov 21 16:48:18 2005 @@ -80,18 +80,41 @@ // Print out module-level global variables here. for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) { - if (I->hasInitializer()) { // External global require no code - O << "\n\n"; - std::string name = Mang->getValueName(I); - Constant *C = I->getInitializer(); - unsigned Size = TD.getTypeSize(C->getType()); - unsigned Align = TD.getTypeAlignmentShift(C->getType()); - - switch (I->getLinkage()) { - default: assert(0 && "Unknown linkage type!"); - case GlobalValue::LinkOnceLinkage: - case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. - if (C->isNullValue()) { + if (!I->hasInitializer()) continue; // External global require no code + + O << "\n\n"; + std::string name = Mang->getValueName(I); + Constant *C = I->getInitializer(); + unsigned Size = TD.getTypeSize(C->getType()); + unsigned Align = TD.getTypeAlignmentShift(C->getType()); + + switch (I->getLinkage()) { + default: assert(0 && "Unknown linkage type!"); + case GlobalValue::LinkOnceLinkage: + case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. + if (C->isNullValue()) { + O << COMMDirective << name << "," << Size; + if (COMMDirectiveTakesAlignment) + O << "," << (1 << Align); + O << "\t\t# "; + WriteAsOperand(O, I, true, true, &M); + O << "\n"; + continue; + } + + // Nonnull linkonce -> weak + O << "\t.weak " << name << "\n"; + O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\", at progbits\n"; + SwitchSection("", I); + break; + case GlobalValue::InternalLinkage: + if (C->isNullValue()) { + if (LCOMMDirective) { + O << LCOMMDirective << name << "," << Size << "," << Align; + continue; + } else { + SwitchSection(".bss", I); + O << "\t.local " << name << "\n"; O << COMMDirective << name << "," << Size; if (COMMDirectiveTakesAlignment) O << "," << (1 << Align); @@ -100,53 +123,30 @@ O << "\n"; continue; } - - // Nonnull linkonce -> weak - O << "\t.weak " << name << "\n"; - O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\", at progbits\n"; - SwitchSection("", I); - break; - case GlobalValue::InternalLinkage: - if (C->isNullValue()) { - if (LCOMMDirective) { - O << LCOMMDirective << name << "," << Size << "," << Align; - continue; - } else { - SwitchSection(".bss", I); - O << "\t.local " << name << "\n"; - O << COMMDirective << name << "," << Size; - if (COMMDirectiveTakesAlignment) - O << "," << (1 << Align); - O << "\t\t# "; - WriteAsOperand(O, I, true, true, &M); - O << "\n"; - continue; - } - } - SwitchSection(C->isNullValue() ? ".bss" : ".data", I); - break; - case GlobalValue::AppendingLinkage: - // FIXME: appending linkage variables should go into a section of - // their name or something. For now, just emit them as external. - case GlobalValue::ExternalLinkage: - SwitchSection(C->isNullValue() ? ".bss" : ".data", I); - // If external or appending, declare as a global symbol - O << "\t.globl " << name << "\n"; - break; } + SwitchSection(".data", I); + break; + case GlobalValue::AppendingLinkage: + // FIXME: appending linkage variables should go into a section of + // their name or something. For now, just emit them as external. + case GlobalValue::ExternalLinkage: + SwitchSection(C->isNullValue() ? ".bss" : ".data", I); + // If external or appending, declare as a global symbol + O << "\t.globl " << name << "\n"; + break; + } - EmitAlignment(Align); - if (forELF) { - O << "\t.type " << name << ", at object\n"; - O << "\t.size " << name << "," << Size << "\n"; - } - O << name << ":\t\t\t\t# "; - WriteAsOperand(O, I, true, true, &M); - O << " = "; - WriteAsOperand(O, C, false, false, &M); - O << "\n"; - EmitGlobalConstant(C); + EmitAlignment(Align); + if (forELF) { + O << "\t.type " << name << ", at object\n"; + O << "\t.size " << name << "," << Size << "\n"; } + O << name << ":\t\t\t\t# "; + WriteAsOperand(O, I, true, true, &M); + O << " = "; + WriteAsOperand(O, C, false, false, &M); + O << "\n"; + EmitGlobalConstant(C); } if (forDarwin) { From lattner at cs.uiuc.edu Mon Nov 21 17:06:20 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 17:06:20 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h Message-ID: <200511212306.RAA30476@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: AsmPrinter.h updated: 1.21 -> 1.22 --- Log message: Add a new flag --- Diffs of the changes: (+6 -1) AsmPrinter.h | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletion(-) Index: llvm/include/llvm/CodeGen/AsmPrinter.h diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.21 llvm/include/llvm/CodeGen/AsmPrinter.h:1.22 --- llvm/include/llvm/CodeGen/AsmPrinter.h:1.21 Mon Nov 21 13:51:51 2005 +++ llvm/include/llvm/CodeGen/AsmPrinter.h Mon Nov 21 17:06:08 2005 @@ -147,6 +147,10 @@ /// COMMDirectiveTakesAlignment - True if COMMDirective take a third /// argument that specifies the alignment of the declaration. bool COMMDirectiveTakesAlignment; // Defaults to true. + + /// HasDotTypeDotSizeDirective - True if the target has .type and .size + /// directives, this is true for most ELF targets. + bool HasDotTypeDotSizeDirective; // Defaults to true. AsmPrinter(std::ostream &o, TargetMachine &tm) : FunctionNumber(0), O(o), TM(tm), @@ -170,7 +174,8 @@ ConstantPoolSection("\t.section .rodata\n"), LCOMMDirective(0), COMMDirective("\t.comm\t"), - COMMDirectiveTakesAlignment(true) { + COMMDirectiveTakesAlignment(true), + HasDotTypeDotSizeDirective(true) { } /// SwitchSection - Switch to the specified section of the executable if we From lattner at cs.uiuc.edu Mon Nov 21 17:07:06 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 21 Nov 2005 17:07:06 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86AsmPrinter.cpp X86AsmPrinter.h X86IntelAsmPrinter.cpp Message-ID: <200511212307.RAA30546@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ATTAsmPrinter.cpp updated: 1.15 -> 1.16 X86AsmPrinter.cpp updated: 1.156 -> 1.157 X86AsmPrinter.h updated: 1.7 -> 1.8 X86IntelAsmPrinter.cpp updated: 1.10 -> 1.11 --- Log message: Use HasDotTypeDotSizeDirective instead of forELF --- Diffs of the changes: (+10 -18) X86ATTAsmPrinter.cpp | 4 ++-- X86AsmPrinter.cpp | 19 ++++++------------- X86AsmPrinter.h | 3 +-- X86IntelAsmPrinter.cpp | 2 +- 4 files changed, 10 insertions(+), 18 deletions(-) Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.15 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.16 --- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.15 Mon Nov 21 16:39:40 2005 +++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Mon Nov 21 17:06:54 2005 @@ -35,7 +35,7 @@ SwitchSection("\t.text\n", MF.getFunction()); EmitAlignment(4); // FIXME: This should be parameterized somewhere. O << "\t.globl\t" << CurrentFnName << "\n"; - if (forELF) + if (HasDotTypeDotSizeDirective) O << "\t.type\t" << CurrentFnName << ", @function\n"; O << CurrentFnName << ":\n"; @@ -54,7 +54,7 @@ printMachineInstruction(II); } } - if (forELF) + if (HasDotTypeDotSizeDirective) O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n"; // We didn't modify anything. Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.156 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.157 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.156 Mon Nov 21 16:48:18 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Mon Nov 21 17:06:54 2005 @@ -43,13 +43,9 @@ bool X86SharedAsmPrinter::doInitialization(Module &M) { const X86Subtarget *Subtarget = &TM.getSubtarget(); - forELF = false; forDarwin = false; switch (Subtarget->TargetType) { - case X86Subtarget::isELF: - forELF = true; - break; case X86Subtarget::isDarwin: AlignmentIsInBytes = false; GlobalPrefix = "_"; @@ -59,14 +55,17 @@ ConstantPoolSection = "\t.const\n"; LCOMMDirective = "\t.lcomm\t"; COMMDirectiveTakesAlignment = false; + HasDotTypeDotSizeDirective = false; forDarwin = true; break; case X86Subtarget::isCygwin: GlobalPrefix = "_"; COMMDirectiveTakesAlignment = false; + HasDotTypeDotSizeDirective = false; break; case X86Subtarget::isWindows: GlobalPrefix = "_"; + HasDotTypeDotSizeDirective = false; break; default: break; } @@ -96,9 +95,7 @@ O << COMMDirective << name << "," << Size; if (COMMDirectiveTakesAlignment) O << "," << (1 << Align); - O << "\t\t# "; - WriteAsOperand(O, I, true, true, &M); - O << "\n"; + O << "\t\t" << CommentString << " " << I->getName() << "\n"; continue; } @@ -137,15 +134,11 @@ } EmitAlignment(Align); - if (forELF) { + if (HasDotTypeDotSizeDirective) { O << "\t.type " << name << ", at object\n"; O << "\t.size " << name << "," << Size << "\n"; } - O << name << ":\t\t\t\t# "; - WriteAsOperand(O, I, true, true, &M); - O << " = "; - WriteAsOperand(O, C, false, false, &M); - O << "\n"; + O << name << ":\t\t\t" << CommentString << ' ' << I->getName() << '\n'; EmitGlobalConstant(C); } Index: llvm/lib/Target/X86/X86AsmPrinter.h diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.7 llvm/lib/Target/X86/X86AsmPrinter.h:1.8 --- llvm/lib/Target/X86/X86AsmPrinter.h:1.7 Mon Nov 21 16:39:40 2005 +++ llvm/lib/Target/X86/X86AsmPrinter.h Mon Nov 21 17:06:54 2005 @@ -29,12 +29,11 @@ struct X86SharedAsmPrinter : public AsmPrinter { X86SharedAsmPrinter(std::ostream &O, TargetMachine &TM) - : AsmPrinter(O, TM), forELF(false), forDarwin(false) { } + : AsmPrinter(O, TM), forDarwin(false) { } bool doInitialization(Module &M); bool doFinalization(Module &M); - bool forELF; bool forDarwin; // FIXME: eliminate. // Necessary for Darwin to print out the apprioriate types of linker stubs Index: llvm/lib/Target/X86/X86IntelAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.10 llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.11 --- llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.10 Mon Nov 21 16:19:48 2005 +++ llvm/lib/Target/X86/X86IntelAsmPrinter.cpp Mon Nov 21 17:06:54 2005 @@ -35,7 +35,7 @@ SwitchSection("\t.text\n", MF.getFunction()); EmitAlignment(4); O << "\t.globl\t" << CurrentFnName << "\n"; - if (forELF) + if (HasDotTypeDotSizeDirective) O << "\t.type\t" << CurrentFnName << ", @function\n"; O << CurrentFnName << ":\n"; From natebegeman at mac.com Mon Nov 21 19:29:49 2005 From: natebegeman at mac.com (Nate Begeman) Date: Mon, 21 Nov 2005 19:29:49 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetLowering.cpp Message-ID: <200511220129.TAA00506@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetLowering.cpp updated: 1.13 -> 1.14 --- Log message: Rather than attempting to legalize 1 x float, make sure the SD ISel never generates it. Make MVT::Vector expand-only, and remove the code in Legalize that attempts to legalize it. The plan for supporting N x Type is to continually epxand it in ExpandOp until it gets down to 2 x Type, where it will be scalarized into a pair of scalars. --- Diffs of the changes: (+5 -1) TargetLowering.cpp | 6 +++++- 1 files changed, 5 insertions(+), 1 deletion(-) Index: llvm/lib/Target/TargetLowering.cpp diff -u llvm/lib/Target/TargetLowering.cpp:1.13 llvm/lib/Target/TargetLowering.cpp:1.14 --- llvm/lib/Target/TargetLowering.cpp:1.13 Thu Oct 20 19:02:42 2005 +++ llvm/lib/Target/TargetLowering.cpp Mon Nov 21 19:29:36 2005 @@ -64,7 +64,7 @@ assert(VT < PromoteTo && "Must promote to a larger type!"); TransformToType[VT] = PromoteTo; } else if (Action == TargetLowering::Expand) { - assert(MVT::isInteger(VT) && VT > MVT::i8 && + assert((VT == MVT::Vector || MVT::isInteger(VT)) && VT > MVT::i8 && "Cannot expand this type: target must support SOME integer reg!"); // Expand to the next smaller integer type! TransformToType[VT] = (MVT::ValueType)(VT-1); @@ -113,6 +113,10 @@ TransformToType, ValueTypeActions); else TransformToType[MVT::f32] = MVT::f32; + + // Set MVT::Vector to always be Expanded + SetValueTypeAction(MVT::Vector, Expand, *this, TransformToType, + ValueTypeActions); assert(isTypeLegal(MVT::f64) && "Target does not support FP?"); TransformToType[MVT::f64] = MVT::f64; From natebegeman at mac.com Mon Nov 21 19:29:49 2005 From: natebegeman at mac.com (Nate Begeman) Date: Mon, 21 Nov 2005 19:29:49 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp SelectionDAGISel.cpp Message-ID: <200511220129.TAA00502@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.213 -> 1.214 SelectionDAGISel.cpp updated: 1.103 -> 1.104 --- Log message: Rather than attempting to legalize 1 x float, make sure the SD ISel never generates it. Make MVT::Vector expand-only, and remove the code in Legalize that attempts to legalize it. The plan for supporting N x Type is to continually epxand it in ExpandOp until it gets down to 2 x Type, where it will be scalarized into a pair of scalars. --- Diffs of the changes: (+24 -48) LegalizeDAG.cpp | 42 ------------------------------------------ SelectionDAGISel.cpp | 30 ++++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 48 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.213 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.214 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.213 Sun Nov 20 16:56:56 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Mon Nov 21 19:29:36 2005 @@ -925,26 +925,6 @@ AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1)); return Result.getValue(Op.ResNo); - case ISD::VLOAD: - Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain. - Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the pointer. - - // If we just have one element, scalarize the result. Otherwise, check to - // see if we support this operation on this type at this width. If not, - // split the vector in half and try again. - if (1 == cast(Node->getOperand(2))->getValue()) { - MVT::ValueType SVT = cast(Node->getOperand(3))->getVT(); - Result = LegalizeOp(DAG.getLoad(SVT, Tmp1, Tmp2, Node->getOperand(4))); - } else { - assert(0 && "Expand case for vectors unimplemented"); - } - - // Since loads produce two values, make sure to remember that we legalized - // both of them. - AddLegalizedOperand(SDOperand(Node, 0), Result); - AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1)); - return Result.getValue(Op.ResNo); - case ISD::EXTLOAD: case ISD::SEXTLOAD: case ISD::ZEXTLOAD: { @@ -1685,28 +1665,6 @@ Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1,Tmp2); break; - // Vector binary operators - case ISD::VADD: - case ISD::VSUB: - case ISD::VMUL: { - Tmp1 = Node->getOperand(0); // Element Count - Tmp2 = Node->getOperand(1); // Element Type - - // If we just have one element, scalarize the result. Otherwise, check to - // see if we support this operation on this type at this width. If not, - // split the vector in half and try again. - if (1 == cast(Tmp1)->getValue()) { - MVT::ValueType SVT = cast(Tmp2)->getVT(); - - Result = DAG.getNode(getScalarizedOpcode(Node->getOpcode(), SVT), SVT, - LegalizeOp(Node->getOperand(2)), - LegalizeOp(Node->getOperand(3))); - } else { - assert(0 && "Expand case for vectors unimplemented"); - } - break; - } - case ISD::BUILD_PAIR: { MVT::ValueType PairTy = Node->getValueType(0); // TODO: handle the case where the Lo and Hi operands are not of legal type Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.103 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.104 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.103 Sat Nov 19 12:40:42 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Nov 21 19:29:36 2005 @@ -517,9 +517,19 @@ setValue(&I, DAG.getNode(FPOp, Op1.getValueType(), Op1, Op2)); } else { const PackedType *PTy = cast(Ty); - SDOperand Num = DAG.getConstant(PTy->getNumElements(), MVT::i32); - SDOperand Typ = DAG.getValueType(TLI.getValueType(PTy->getElementType())); - setValue(&I, DAG.getNode(VecOp, Op1.getValueType(), Num, Typ, Op1, Op2)); + unsigned NumElements = PTy->getNumElements(); + MVT::ValueType PVT = TLI.getValueType(PTy->getElementType()); + + // Immediately scalarize packed types containing only one element, so that + // the Legalize pass does not have to deal with them. + if (NumElements == 1) { + unsigned Opc = MVT::isFloatingPoint(PVT) ? FPOp : IntOp; + setValue(&I, DAG.getNode(Opc, PVT, Op1, Op2)); + } else { + SDOperand Num = DAG.getConstant(NumElements, MVT::i32); + SDOperand Typ = DAG.getValueType(PVT); + setValue(&I, DAG.getNode(VecOp, Op1.getValueType(), Num, Typ, Op1, Op2)); + } } } @@ -726,9 +736,17 @@ if (Type::PackedTyID == Ty->getTypeID()) { const PackedType *PTy = cast(Ty); - L = DAG.getVecLoad(PTy->getNumElements(), - TLI.getValueType(PTy->getElementType()), Root, Ptr, - DAG.getSrcValue(I.getOperand(0))); + unsigned NumElements = PTy->getNumElements(); + MVT::ValueType PVT = TLI.getValueType(PTy->getElementType()); + + // Immediately scalarize packed types containing only one element, so that + // the Legalize pass does not have to deal with them. + if (NumElements == 1) { + L = DAG.getLoad(PVT, Root, Ptr, DAG.getSrcValue(I.getOperand(0))); + } else { + L = DAG.getVecLoad(NumElements, PVT, Root, Ptr, + DAG.getSrcValue(I.getOperand(0))); + } } else { L = DAG.getLoad(TLI.getValueType(Ty), Root, Ptr, DAG.getSrcValue(I.getOperand(0))); From alenhar2 at cs.uiuc.edu Mon Nov 21 22:20:17 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 21 Nov 2005 22:20:17 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaCodeEmitter.cpp AlphaISelDAGToDAG.cpp AlphaISelPattern.cpp AlphaInstrFormats.td AlphaInstrInfo.td Message-ID: <200511220420.WAA02032@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaCodeEmitter.cpp updated: 1.7 -> 1.8 AlphaISelDAGToDAG.cpp updated: 1.5 -> 1.6 AlphaISelPattern.cpp updated: 1.185 -> 1.186 AlphaInstrFormats.td updated: 1.13 -> 1.14 AlphaInstrInfo.td updated: 1.72 -> 1.73 --- Log message: massive DAGISel patch. lots and lots more stuff compiles now --- Diffs of the changes: (+207 -52) AlphaCodeEmitter.cpp | 4 - AlphaISelDAGToDAG.cpp | 151 +++++++++++++++++++++++++++++++++++++++----------- AlphaISelPattern.cpp | 12 +++ AlphaInstrFormats.td | 4 - AlphaInstrInfo.td | 88 +++++++++++++++++++++++------ 5 files changed, 207 insertions(+), 52 deletions(-) Index: llvm/lib/Target/Alpha/AlphaCodeEmitter.cpp diff -u llvm/lib/Target/Alpha/AlphaCodeEmitter.cpp:1.7 llvm/lib/Target/Alpha/AlphaCodeEmitter.cpp:1.8 --- llvm/lib/Target/Alpha/AlphaCodeEmitter.cpp:1.7 Wed Nov 16 15:15:53 2005 +++ llvm/lib/Target/Alpha/AlphaCodeEmitter.cpp Mon Nov 21 22:20:06 2005 @@ -117,7 +117,9 @@ case Alpha::ALTENT: case Alpha::PCLABEL: case Alpha::MEMLABEL: - case Alpha::IDEF: + case Alpha::IDEF_I: + case Alpha::IDEF_F32: + case Alpha::IDEF_F64: break; //skip these } } Index: llvm/lib/Target/Alpha/AlphaISelDAGToDAG.cpp diff -u llvm/lib/Target/Alpha/AlphaISelDAGToDAG.cpp:1.5 llvm/lib/Target/Alpha/AlphaISelDAGToDAG.cpp:1.6 --- llvm/lib/Target/Alpha/AlphaISelDAGToDAG.cpp:1.5 Wed Oct 26 13:44:46 2005 +++ llvm/lib/Target/Alpha/AlphaISelDAGToDAG.cpp Mon Nov 21 22:20:06 2005 @@ -38,6 +38,10 @@ class AlphaDAGToDAGISel : public SelectionDAGISel { AlphaTargetLowering AlphaLowering; + static const int IMM_LOW = -32768; + static const int IMM_HIGH = 32767; + static const int IMM_MULT = 65536; + public: AlphaDAGToDAGISel(TargetMachine &TM) : SelectionDAGISel(AlphaLowering), AlphaLowering(TM) {} @@ -108,13 +112,42 @@ case ISD::TAILCALL: case ISD::CALL: return SelectCALL(Op); - case ISD::DYNAMIC_STACKALLOC: - assert(0 && "You want these too?"); + case ISD::DYNAMIC_STACKALLOC: { + if (!isa(N->getOperand(2)) || + cast(N->getOperand(2))->getValue() != 0) { + std::cerr << "Cannot allocate stack object with greater alignment than" + << " the stack alignment yet!"; + abort(); + } + SDOperand Chain = Select(N->getOperand(0)); + SDOperand Amt = Select(N->getOperand(1)); + SDOperand Reg = CurDAG->getRegister(Alpha::R30, MVT::i64); + SDOperand Val = CurDAG->getCopyFromReg(Chain, Alpha::R30, MVT::i64); + Chain = Val.getValue(1); + + // Subtract the amount (guaranteed to be a multiple of the stack alignment) + // from the stack pointer, giving us the result pointer. + SDOperand Result = CurDAG->getTargetNode(Alpha::SUBQ, MVT::i64, Val, Amt); + + // Copy this result back into R30. + Chain = CurDAG->getNode(ISD::CopyToReg, MVT::Other, Chain, Reg, Result); + + // Copy this result back out of R30 to make sure we're not using the stack + // space without decrementing the stack pointer. + Result = CurDAG->getCopyFromReg(Chain, Alpha::R30, MVT::i64); + + // Finally, replace the DYNAMIC_STACKALLOC with the copyfromreg. + CodeGenMap[Op.getValue(0)] = Result; + CodeGenMap[Op.getValue(1)] = Result.getValue(1); + return SDOperand(Result.Val, Op.ResNo); + } case ISD::BRCOND: { SDOperand Chain = Select(N->getOperand(0)); SDOperand CC = Select(N->getOperand(1)); - CurDAG->SelectNodeTo(N, Alpha::BNE, MVT::Other, CC, Chain); + MachineBasicBlock *Dest = + cast(N->getOperand(2))->getBasicBlock(); + CurDAG->SelectNodeTo(N, Alpha::BNE, MVT::Other, CC, CurDAG->getBasicBlock(Dest), Chain); return SDOperand(N, 0); } case ISD::LOAD: @@ -148,6 +181,33 @@ getI64Imm(0), Address, Chain); return SDOperand(N, Op.ResNo); } + case ISD::STORE: + case ISD::TRUNCSTORE: { + SDOperand Chain = Select(N->getOperand(0)); + SDOperand Value = Select(N->getOperand(1)); + SDOperand Address = Select(N->getOperand(2)); + + unsigned Opc = Alpha::WTF; + + if (N->getOpcode() == ISD::STORE) { + switch (N->getOperand(1).getValueType()) { + case MVT::i64: Opc = Alpha::STQ; break; + case MVT::f64: Opc = Alpha::STT; break; + case MVT::f32: Opc = Alpha::STS; break; + default: assert(0 && "Bad store!"); + }; + } else { //TRUNCSTORE + switch (cast(N->getOperand(4))->getVT()) { + case MVT::i32: Opc = Alpha::STL; break; + case MVT::i16: Opc = Alpha::STW; break; + case MVT::i8: Opc = Alpha::STB; break; + default: assert(0 && "Bad truncstore!"); + }; + } + CurDAG->SelectNodeTo(N, Opc, MVT::Other, Value, getI64Imm(0), Address, + Chain); + return SDOperand(N, 0); + } case ISD::BR: { CurDAG->SelectNodeTo(N, Alpha::BR_DAG, MVT::Other, N->getOperand(1), @@ -155,32 +215,19 @@ return SDOperand(N, 0); } - case ISD::UNDEF: - if (N->getValueType(0) == MVT::i64) - CurDAG->SelectNodeTo(N, Alpha::IDEF, MVT::i64); -// else if (N->getValueType(0) == MVT::f32) -// CurDAG->SelectNodeTo(N, PPC::IMPLICIT_DEF_F4, MVT::f32); -// else -// CurDAG->SelectNodeTo(N, PPC::IMPLICIT_DEF_F8, MVT::f64); - return SDOperand(N, 0); case ISD::FrameIndex: { -// int FI = cast(N)->getIndex(); -// CurDAG->SelectNodeTo(N, Alpha::LDA, MVT::i64, -// CurDAG->getTargetFrameIndex(FI, MVT::i32), -// getI32Imm(0)); -// return SDOperand(N, 0); - assert(0 && "Frame?, you are suppose to look through the window, not at the frame!"); + int FI = cast(N)->getIndex(); + CurDAG->SelectNodeTo(N, Alpha::LDA, MVT::i64, + CurDAG->getTargetFrameIndex(FI, MVT::i32), + getI64Imm(0)); + return SDOperand(N, 0); } case ISD::ConstantPool: { -// Constant *C = cast(N)->get(); -// SDOperand Tmp, CPI = CurDAG->getTargetConstantPool(C, MVT::i32); -// if (PICEnabled) -// Tmp = CurDAG->getTargetNode(PPC::ADDIS, MVT::i32, getGlobalBaseReg(),CPI); -// else -// Tmp = CurDAG->getTargetNode(PPC::LIS, MVT::i32, CPI); -// CurDAG->SelectNodeTo(N, PPC::LA, MVT::i32, Tmp, CPI); -// return SDOperand(N, 0); - assert(0 && "Constants are overrated"); + Constant *C = cast(N)->get(); + SDOperand Tmp, CPI = CurDAG->getTargetConstantPool(C, MVT::i64); + Tmp = CurDAG->getTargetNode(Alpha::LDAHr, MVT::i64, CPI, getGlobalBaseReg()); + CurDAG->SelectNodeTo(N, Alpha::LDAr, MVT::i64, CPI, Tmp); + return SDOperand(N, 0); } case ISD::GlobalAddress: { GlobalValue *GV = cast(N)->getGlobal(); @@ -219,15 +266,45 @@ CurDAG->SelectNodeTo(N, Alpha::RETDAG, MVT::Other, Chain); return SDOperand(N, 0); } - - - + case ISD::Constant: { + int64_t val = (int64_t)cast(N)->getValue(); + if (val > (int64_t)IMM_HIGH +(int64_t)IMM_HIGH* (int64_t)IMM_MULT || + val < (int64_t)IMM_LOW + (int64_t)IMM_LOW * (int64_t)IMM_MULT) { + MachineConstantPool *CP = BB->getParent()->getConstantPool(); + ConstantUInt *C = + ConstantUInt::get(Type::getPrimitiveType(Type::ULongTyID) , val); + SDOperand Tmp, CPI = CurDAG->getTargetConstantPool(C, MVT::i64); + Tmp = CurDAG->getTargetNode(Alpha::LDAHr, MVT::i64, CPI, getGlobalBaseReg()); + CurDAG->SelectNodeTo(N, Alpha::LDAr, MVT::i64, CPI, Tmp); + return SDOperand(N, 0); + } + } + case ISD::ConstantFP: + if (ConstantFPSDNode *CN = dyn_cast(N)) { + bool isDouble = N->getValueType(0) == MVT::f64; + MVT::ValueType T = isDouble ? MVT::f64 : MVT::f32; + if (CN->isExactlyValue(+0.0)) { + CurDAG->SelectNodeTo(N, isDouble ? Alpha::CPYST : Alpha::CPYSS, T, + CurDAG->getRegister(Alpha::F31, T), + CurDAG->getRegister(Alpha::F31, T)); + return SDOperand(N, 0); + } else if ( CN->isExactlyValue(-0.0)) { + CurDAG->SelectNodeTo(N, isDouble ? Alpha::CPYSNT : Alpha::CPYSNS, T, + CurDAG->getRegister(Alpha::F31, T), + CurDAG->getRegister(Alpha::F31, T)); + return SDOperand(N, 0); + } else { + abort(); + } + } } return SelectCode(Op); } SDOperand AlphaDAGToDAGISel::SelectCALL(SDOperand Op) { + //TODO: add flag stuff to prevent nondeturministic breakage! + SDNode *N = Op.Val; SDOperand Chain = Select(N->getOperand(0)); SDOperand Addr = Select(N->getOperand(1)); @@ -251,10 +328,12 @@ for (int i = 0; i < std::min(6, count); ++i) { if (MVT::isInteger(TypeOperands[i])) { Chain = CurDAG->getCopyToReg(Chain, args_int[i], CallOperands[i]); - } else { - assert(0 && "No FP support yet"); - } + } else if (TypeOperands[i] == MVT::f64 || TypeOperands[i] == MVT::f64) { + Chain = CurDAG->getCopyToReg(Chain, args_float[i], CallOperands[i]); + } else + assert(0 && "Unknown operand"); } + assert(CallOperands.size() <= 6 && "Too big a call"); Chain = CurDAG->getCopyToReg(Chain, Alpha::R27, Addr); @@ -271,6 +350,14 @@ Chain = CurDAG->getCopyFromReg(Chain, Alpha::R0, MVT::i64).getValue(1); CallResults.push_back(Chain.getValue(0)); break; + case MVT::f32: + Chain = CurDAG->getCopyFromReg(Chain, Alpha::F0, MVT::f32).getValue(1); + CallResults.push_back(Chain.getValue(0)); + break; + case MVT::f64: + Chain = CurDAG->getCopyFromReg(Chain, Alpha::F0, MVT::f64).getValue(1); + CallResults.push_back(Chain.getValue(0)); + break; } CallResults.push_back(Chain); Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.185 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.186 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.185 Sat Nov 12 13:06:28 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Mon Nov 21 22:20:06 2005 @@ -592,7 +592,9 @@ return Result; } case ISD::UNDEF: { - BuildMI(BB, Alpha::IDEF, 0, Result); + Opc = isFP ? (DestType == MVT::f32 ? Alpha::IDEF_F32 : Alpha::IDEF_F64) + : Alpha::IDEF_I; + BuildMI(BB, Opc, 0, Result); return Result; } @@ -1610,7 +1612,13 @@ case ISD::ImplicitDef: ++count_ins; Select(N.getOperand(0)); - BuildMI(BB, Alpha::IDEF, 0, + switch(N.getValueType()) { + case MVT::f32: Opc = Alpha::IDEF_F32; break; + case MVT::f64: Opc = Alpha::IDEF_F64; break; + case MVT::i64: Opc = Alpha::IDEF_I; break; + default: assert(0 && "should have been legalized"); + }; + BuildMI(BB, Opc, 0, cast(N.getOperand(1))->getReg()); return; Index: llvm/lib/Target/Alpha/AlphaInstrFormats.td diff -u llvm/lib/Target/Alpha/AlphaInstrFormats.td:1.13 llvm/lib/Target/Alpha/AlphaInstrFormats.td:1.14 --- llvm/lib/Target/Alpha/AlphaInstrFormats.td:1.13 Fri Nov 11 10:46:18 2005 +++ llvm/lib/Target/Alpha/AlphaInstrFormats.td Mon Nov 21 22:20:06 2005 @@ -218,5 +218,7 @@ // Pseudo instructions. -class PseudoInstAlpha : InstAlpha<0, OL, nm> { +class PseudoInstAlpha pattern> : InstAlpha<0, OL, nm> { + let Pattern = pattern; + } Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.72 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.73 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.72 Fri Nov 11 10:46:18 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Mon Nov 21 22:20:06 2005 @@ -74,15 +74,22 @@ // //#define GP $29 // //#define SP $30 -def PHI : PseudoInstAlpha<(ops variable_ops), "#phi">; -def IDEF : PseudoInstAlpha<(ops GPRC:$RA), "#idef $RA">; -def WTF : PseudoInstAlpha<(ops variable_ops), "#wtf">; -def ADJUSTSTACKUP : PseudoInstAlpha<(ops variable_ops), "ADJUP">; -def ADJUSTSTACKDOWN : PseudoInstAlpha<(ops variable_ops), "ADJDOWN">; -def ALTENT : PseudoInstAlpha<(ops s64imm:$TARGET), "$TARGET:\n">; -def PCLABEL : PseudoInstAlpha<(ops s64imm:$num), "PCMARKER_$num:\n">; +def PHI : PseudoInstAlpha<(ops variable_ops), "#phi", []>; + +def IDEF_I : PseudoInstAlpha<(ops GPRC:$RA), "#idef $RA", + [(set GPRC:$RA, (undef))]>; +def IDEF_F32 : PseudoInstAlpha<(ops F4RC:$RA), "#idef $RA", + [(set F4RC:$RA, (undef))]>; +def IDEF_F64 : PseudoInstAlpha<(ops F8RC:$RA), "#idef $RA", + [(set F8RC:$RA, (undef))]>; + +def WTF : PseudoInstAlpha<(ops variable_ops), "#wtf", []>; +def ADJUSTSTACKUP : PseudoInstAlpha<(ops variable_ops), "ADJUP", []>; +def ADJUSTSTACKDOWN : PseudoInstAlpha<(ops variable_ops), "ADJDOWN", []>; +def ALTENT : PseudoInstAlpha<(ops s64imm:$TARGET), "$TARGET:\n", []>; +def PCLABEL : PseudoInstAlpha<(ops s64imm:$num), "PCMARKER_$num:\n",[]>; def MEMLABEL : PseudoInstAlpha<(ops s64imm:$i, s64imm:$j, s64imm:$k, s64imm:$m), - "LSMARKER$$$i$$$j$$$k$$$m:\n">; + "LSMARKER$$$i$$$j$$$k$$$m:\n",[]>; //***************** //These are shortcuts, the assembler expands them @@ -97,19 +104,19 @@ let isTwoAddress = 1 in { //Conditional move of an int based on a FP CC def CMOVEQ_FP : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, GPRC:$RSRC_T, F8RC:$RCOND), - "fbne $RCOND, 42f\n\tbis $RSRC_T,$RSRC_T,$RDEST\n42:\n">; + "fbne $RCOND, 42f\n\tbis $RSRC_T,$RSRC_T,$RDEST\n42:\n", []>; def CMOVEQi_FP : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, u8imm:$L, F8RC:$RCOND), - "fbne $RCOND, 42f\n\taddq $$31,$L,$RDEST\n42:\n">; + "fbne $RCOND, 42f\n\taddq $$31,$L,$RDEST\n42:\n", []>; def CMOVNE_FP : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, GPRC:$RSRC_T, F8RC:$RCOND), - "fbeq $RCOND, 42f\n\tbis $RSRC_T,$RSRC_T,$RDEST\n42:\n">; + "fbeq $RCOND, 42f\n\tbis $RSRC_T,$RSRC_T,$RDEST\n42:\n", []>; def CMOVNEi_FP : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, u8imm:$L, F8RC:$RCOND), - "fbeq $RCOND, 42f\n\taddq $$31,$L,$RDEST\n42:\n">; + "fbeq $RCOND, 42f\n\taddq $$31,$L,$RDEST\n42:\n", []>; //Conditional move of an FP based on a Int CC def FCMOVEQ_INT : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, GPRC:$RSRC_T, F8RC:$RCOND), - "bne $RCOND, 42f\n\tcpys $RSRC_T,$RSRC_T,$RDEST\n42:\n">; + "bne $RCOND, 42f\n\tcpys $RSRC_T,$RSRC_T,$RDEST\n42:\n", []>; def FCMOVNE_INT : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, GPRC:$RSRC_T, F8RC:$RCOND), - "beq $RCOND, 42f\n\tcpys $RSRC_T,$RSRC_T,$RDEST\n42:\n">; + "beq $RCOND, 42f\n\tcpys $RSRC_T,$RSRC_T,$RDEST\n42:\n", []>; } //*********************** @@ -330,9 +337,9 @@ def CMPULEi : OFormL<0x10, 0x3D, "cmpule $RA,$L,$RC", [(set GPRC:$RC, (setule GPRC:$RA, immUExt8:$L))]>; def CMPULT : OForm< 0x10, 0x1D, "cmpult $RA,$RB,$RC", - [(set GPRC:$RC, (setlt GPRC:$RA, GPRC:$RB))]>; + [(set GPRC:$RC, (setult GPRC:$RA, GPRC:$RB))]>; def CMPULTi : OFormL<0x10, 0x1D, "cmpult $RA,$L,$RC", - [(set GPRC:$RC, (setlt GPRC:$RA, immUExt8:$L))]>; + [(set GPRC:$RC, (setult GPRC:$RA, immUExt8:$L))]>; //Patterns for unsupported int comparisons def : Pat<(setueq GPRC:$X, GPRC:$Y), (CMPEQ GPRC:$X, GPRC:$Y)>; @@ -588,7 +595,56 @@ //def AMASKi : OFormL<0x11, 0x61, "AMASK $RA,$L,$RC", []>; //Architecture mask +//Constant handling +def immConst2Part : PatLeaf<(imm), [{ + // immZAP predicate - True if the immediate fits is suitable for use in a + // ZAP instruction + int64_t val = (int64_t)N->getValue(); + return (val <= (int64_t)IMM_HIGH +(int64_t)IMM_HIGH* (int64_t)IMM_MULT & + val >= (int64_t)IMM_LOW + (int64_t)IMM_LOW * (int64_t)IMM_MULT); +}]>; + +//TODO: factor this out +def LL16 : SDNodeXFormgetValue(); + int64_t y = l / IMM_MULT; + if (l % IMM_MULT > IMM_HIGH) + ++y; + return getI64Imm(l - y * IMM_MULT); +}]>; +//TODO: factor this out +def LH16 : SDNodeXFormgetValue(); + int64_t y = l / IMM_MULT; + if (l % IMM_MULT > IMM_HIGH) + ++y; + return getI64Imm(y); +}]>; + +def : Pat<(i64 immConst2Part:$imm), + (LDA (LL16 immConst2Part:$imm), (LDAH (LH16 immConst2Part:$imm), R31))>; def : Pat<(i64 immSExt16:$imm), (LDA immSExt16:$imm, R31)>; + +//TODO: I want to just define these like this! +//def : Pat<(i64 0), +// (R31)>; +//def : Pat<(f64 0.0), +// (F31)>; +//def : Pat<(f64 -0.0), +// (CPYSNT F31, F31)>; +//def : Pat<(f32 0.0), +// (F31)>; +//def : Pat<(f32 -0.0), +// (CPYSNS F31, F31)>; + +//Misc Patterns: + +def : Pat<(sext_inreg GPRC:$RB, i32), + (ADDLi GPRC:$RB, 0)>; + +def : Pat<(select GPRC:$which, GPRC:$src1, GPRC:$src2), + (CMOVEQ GPRC:$src1, GPRC:$src2, GPRC:$which)>; //may be CMOVNE + From natebegeman at mac.com Tue Nov 22 12:16:12 2005 From: natebegeman at mac.com (Nate Begeman) Date: Tue, 22 Nov 2005 12:16:12 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAGNodes.h Message-ID: <200511221816.MAA06487@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: SelectionDAGNodes.h updated: 1.77 -> 1.78 --- Log message: Check in code to scalarize arbitrarily wide packed types for some simple vector operations (load, add, sub, mul). This allows us to codegen: void %foo(<4 x float> * %a) { entry: %tmp1 = load <4 x float> * %a; %tmp2 = add <4 x float> %tmp1, %tmp1 store <4 x float> %tmp2, <4 x float> *%a ret void } on ppc as: _foo: lfs f0, 12(r3) lfs f1, 8(r3) lfs f2, 4(r3) lfs f3, 0(r3) fadds f0, f0, f0 fadds f1, f1, f1 fadds f2, f2, f2 fadds f3, f3, f3 stfs f0, 12(r3) stfs f1, 8(r3) stfs f2, 4(r3) stfs f3, 0(r3) blr --- Diffs of the changes: (+3 -1) SelectionDAGNodes.h | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.77 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.78 --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.77 Sun Nov 20 16:55:57 2005 +++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Tue Nov 22 12:15:59 2005 @@ -123,7 +123,9 @@ // Simple abstract vector operators. Unlike the integer and floating point // binary operators, these nodes also take two additional operands: // a constant element count, and a value type node indicating the type of - // the elements. The order is count, type, op0, op1. + // the elements. The order is op0, op1, count, type. All vector opcodes, + // including VLOAD, must currently have count and type as their 3rd and 4th + // arguments. VADD, VSUB, VMUL, // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing From natebegeman at mac.com Tue Nov 22 12:16:12 2005 From: natebegeman at mac.com (Nate Begeman) Date: Tue, 22 Nov 2005 12:16:12 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp SelectionDAG.cpp SelectionDAGISel.cpp Message-ID: <200511221816.MAA06495@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.214 -> 1.215 SelectionDAG.cpp updated: 1.214 -> 1.215 SelectionDAGISel.cpp updated: 1.104 -> 1.105 --- Log message: Check in code to scalarize arbitrarily wide packed types for some simple vector operations (load, add, sub, mul). This allows us to codegen: void %foo(<4 x float> * %a) { entry: %tmp1 = load <4 x float> * %a; %tmp2 = add <4 x float> %tmp1, %tmp1 store <4 x float> %tmp2, <4 x float> *%a ret void } on ppc as: _foo: lfs f0, 12(r3) lfs f1, 8(r3) lfs f2, 4(r3) lfs f3, 0(r3) fadds f0, f0, f0 fadds f1, f1, f1 fadds f2, f2, f2 fadds f3, f3, f3 stfs f0, 12(r3) stfs f1, 8(r3) stfs f2, 4(r3) stfs f3, 0(r3) blr --- Diffs of the changes: (+81 -5) LegalizeDAG.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++++++-- SelectionDAG.cpp | 2 - SelectionDAGISel.cpp | 2 - 3 files changed, 81 insertions(+), 5 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.214 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.215 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.214 Mon Nov 21 19:29:36 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Tue Nov 22 12:16:00 2005 @@ -1121,6 +1121,7 @@ case Expand: SDOperand Lo, Hi; + unsigned IncrementSize; ExpandOp(Node->getOperand(1), Lo, Hi); if (!TLI.isLittleEndian()) @@ -1128,7 +1129,16 @@ Lo = DAG.getNode(ISD::STORE, MVT::Other, Tmp1, Lo, Tmp2, Node->getOperand(3)); - unsigned IncrementSize = MVT::getSizeInBits(Hi.getValueType())/8; + // If this is a vector type, then we have to calculate the increment as + // the product of the element size in bytes, and the number of elements + // in the high half of the vector. + if (MVT::Vector == Hi.getValueType()) { + unsigned NumElems = cast(Hi.getOperand(2))->getValue(); + MVT::ValueType EVT = cast(Hi.getOperand(3))->getVT(); + IncrementSize = NumElems * MVT::getSizeInBits(EVT)/8; + } else { + IncrementSize = MVT::getSizeInBits(Hi.getValueType())/8; + } Tmp2 = DAG.getNode(ISD::ADD, Tmp2.getValueType(), Tmp2, getIntPtrConstant(IncrementSize)); assert(isTypeLegal(Tmp2.getValueType()) && @@ -3001,8 +3011,9 @@ MVT::ValueType NVT = TLI.getTypeToTransformTo(VT); SDNode *Node = Op.Val; assert(getTypeAction(VT) == Expand && "Not an expanded type!"); - assert(MVT::isInteger(VT) && "Cannot expand FP values!"); - assert(MVT::isInteger(NVT) && NVT < VT && + assert((MVT::isInteger(VT) || VT == MVT::Vector) && + "Cannot expand FP values!"); + assert(((MVT::isInteger(NVT) && NVT < VT) || VT == MVT::Vector) && "Cannot expand to FP value or to larger int value!"); // See if we already expanded it. @@ -3107,6 +3118,71 @@ std::swap(Lo, Hi); break; } + case ISD::VLOAD: { + SDOperand Ch = LegalizeOp(Node->getOperand(0)); // Legalize the chain. + SDOperand Ptr = LegalizeOp(Node->getOperand(1)); // Legalize the pointer. + unsigned NumElements =cast(Node->getOperand(2))->getValue(); + MVT::ValueType EVT = cast(Node->getOperand(3))->getVT(); + + // If we only have two elements, turn into a pair of scalar loads. + // FIXME: handle case where a vector of two elements is fine, such as + // 2 x double on SSE2. + if (NumElements == 2) { + Lo = DAG.getLoad(EVT, Ch, Ptr, Node->getOperand(4)); + // Increment the pointer to the other half. + unsigned IncrementSize = MVT::getSizeInBits(EVT)/8; + Ptr = DAG.getNode(ISD::ADD, Ptr.getValueType(), Ptr, + getIntPtrConstant(IncrementSize)); + //Is this safe? declaring that the two parts of the split load + //are from the same instruction? + Hi = DAG.getLoad(EVT, Ch, Ptr, Node->getOperand(4)); + } else { + NumElements /= 2; // Split the vector in half + Lo = DAG.getVecLoad(NumElements, EVT, Ch, Ptr, Node->getOperand(4)); + unsigned IncrementSize = NumElements * MVT::getSizeInBits(EVT)/8; + Ptr = DAG.getNode(ISD::ADD, Ptr.getValueType(), Ptr, + getIntPtrConstant(IncrementSize)); + //Is this safe? declaring that the two parts of the split load + //are from the same instruction? + Hi = DAG.getVecLoad(NumElements, EVT, Ch, Ptr, Node->getOperand(4)); + } + + // Build a factor node to remember that this load is independent of the + // other one. + SDOperand TF = DAG.getNode(ISD::TokenFactor, MVT::Other, Lo.getValue(1), + Hi.getValue(1)); + + // Remember that we legalized the chain. + AddLegalizedOperand(Op.getValue(1), TF); + if (!TLI.isLittleEndian()) + std::swap(Lo, Hi); + break; + } + case ISD::VADD: + case ISD::VSUB: + case ISD::VMUL: { + unsigned NumElements =cast(Node->getOperand(2))->getValue(); + MVT::ValueType EVT = cast(Node->getOperand(3))->getVT(); + SDOperand LL, LH, RL, RH; + + ExpandOp(Node->getOperand(0), LL, LH); + ExpandOp(Node->getOperand(1), RL, RH); + + // If we only have two elements, turn into a pair of scalar loads. + // FIXME: handle case where a vector of two elements is fine, such as + // 2 x double on SSE2. + if (NumElements == 2) { + unsigned Opc = getScalarizedOpcode(Node->getOpcode(), EVT); + Lo = DAG.getNode(Opc, EVT, LL, RL); + Hi = DAG.getNode(Opc, EVT, LH, RH); + } else { + Lo = DAG.getNode(Node->getOpcode(), MVT::Vector, LL, RL, LL.getOperand(2), + LL.getOperand(3)); + Hi = DAG.getNode(Node->getOpcode(), MVT::Vector, LH, RH, LH.getOperand(2), + LH.getOperand(3)); + } + break; + } case ISD::TAILCALL: case ISD::CALL: { SDOperand Chain = LegalizeOp(Node->getOperand(0)); // Legalize the chain. Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.214 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.215 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.214 Fri Nov 18 19:44:53 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Nov 22 12:16:00 2005 @@ -1106,7 +1106,7 @@ Ops.push_back(SV); std::vector VTs; VTs.reserve(2); - VTs.push_back(EVT); VTs.push_back(MVT::Other); // Add token chain. + VTs.push_back(MVT::Vector); VTs.push_back(MVT::Other); // Add token chain. return getNode(ISD::VLOAD, VTs, Ops); } Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.104 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.105 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.104 Mon Nov 21 19:29:36 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Tue Nov 22 12:16:00 2005 @@ -528,7 +528,7 @@ } else { SDOperand Num = DAG.getConstant(NumElements, MVT::i32); SDOperand Typ = DAG.getValueType(PVT); - setValue(&I, DAG.getNode(VecOp, Op1.getValueType(), Num, Typ, Op1, Op2)); + setValue(&I, DAG.getNode(VecOp, MVT::Vector, Op1, Op2, Num, Typ)); } } } From alenhar2 at cs.uiuc.edu Tue Nov 22 14:56:18 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 22 Nov 2005 14:56:18 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200511222056.OAA10388@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.186 -> 1.187 --- Log message: Fix warning --- Diffs of the changes: (+3 -3) AlphaISelPattern.cpp | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.186 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.187 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.186 Mon Nov 21 22:20:06 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Tue Nov 22 14:56:05 2005 @@ -1616,7 +1616,7 @@ case MVT::f32: Opc = Alpha::IDEF_F32; break; case MVT::f64: Opc = Alpha::IDEF_F64; break; case MVT::i64: Opc = Alpha::IDEF_I; break; - default: assert(0 && "should have been legalized"); + default: Opc = 0; assert(0 && "should have been legalized"); }; BuildMI(BB, Opc, 0, cast(N.getOperand(1))->getReg()); @@ -1702,14 +1702,14 @@ if (opcode == ISD::STORE) { switch(Value.getValueType()) { - default: assert(0 && "unknown Type in store"); + default: Opc = 0; assert(0 && "unknown Type in store"); case MVT::i64: Opc = Alpha::STQ; break; case MVT::f64: Opc = Alpha::STT; break; case MVT::f32: Opc = Alpha::STS; break; } } else { //ISD::TRUNCSTORE switch(cast(Node->getOperand(4))->getVT()) { - default: assert(0 && "unknown Type in store"); + default: Opc = 0; assert(0 && "unknown Type in store"); case MVT::i8: Opc = Alpha::STB; break; case MVT::i16: Opc = Alpha::STW; break; case MVT::i32: Opc = Alpha::STL; break; From alenhar2 at cs.uiuc.edu Tue Nov 22 14:59:12 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 22 Nov 2005 14:59:12 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200511222059.OAA10429@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.187 -> 1.188 --- Log message: Fix warning, the better way. Really, this is what this instruction is for, so use it --- Diffs of the changes: (+7 -7) AlphaISelPattern.cpp | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.187 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.188 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.187 Tue Nov 22 14:56:05 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Tue Nov 22 14:59:00 2005 @@ -280,7 +280,7 @@ void AlphaISel::MoveFP2Int(unsigned src, unsigned dst, bool isDouble) { - unsigned Opc; + unsigned Opc = Alpha::WTF; if (TLI.getTargetMachine().getSubtarget().hasF2I()) { Opc = isDouble ? Alpha::FTOIT : Alpha::FTOIS; BuildMI(BB, Opc, 1, dst).addReg(src).addReg(Alpha::F31); @@ -307,7 +307,7 @@ void AlphaISel::MoveInt2FP(unsigned src, unsigned dst, bool isDouble) { - unsigned Opc; + unsigned Opc = Alpha::WTF; if (TLI.getTargetMachine().getSubtarget().hasF2I()) { Opc = isDouble?Alpha::ITOFT:Alpha::ITOFS; BuildMI(BB, Opc, 1, dst).addReg(src).addReg(Alpha::R31); @@ -335,7 +335,7 @@ bool AlphaISel::SelectFPSetCC(SDOperand N, unsigned dst) { SDNode *SetCC = N.Val; - unsigned Opc, Tmp1, Tmp2, Tmp3; + unsigned Tmp1, Tmp2, Tmp3, Opc = Alpha::WTF; ISD::CondCode CC = cast(SetCC->getOperand(2))->get(); bool rev = false; bool inv = false; @@ -1581,7 +1581,7 @@ } void AlphaISel::Select(SDOperand N) { - unsigned Tmp1, Tmp2, Opc; + unsigned Tmp1, Tmp2, Opc = Alpha::WTF; unsigned opcode = N.getOpcode(); if (!ExprMap.insert(std::make_pair(N, notIn)).second) @@ -1616,7 +1616,7 @@ case MVT::f32: Opc = Alpha::IDEF_F32; break; case MVT::f64: Opc = Alpha::IDEF_F64; break; case MVT::i64: Opc = Alpha::IDEF_I; break; - default: Opc = 0; assert(0 && "should have been legalized"); + default: assert(0 && "should have been legalized"); }; BuildMI(BB, Opc, 0, cast(N.getOperand(1))->getReg()); @@ -1702,14 +1702,14 @@ if (opcode == ISD::STORE) { switch(Value.getValueType()) { - default: Opc = 0; assert(0 && "unknown Type in store"); + default: assert(0 && "unknown Type in store"); case MVT::i64: Opc = Alpha::STQ; break; case MVT::f64: Opc = Alpha::STT; break; case MVT::f32: Opc = Alpha::STS; break; } } else { //ISD::TRUNCSTORE switch(cast(Node->getOperand(4))->getVT()) { - default: Opc = 0; assert(0 && "unknown Type in store"); + default: assert(0 && "unknown Type in store"); case MVT::i8: Opc = Alpha::STB; break; case MVT::i16: Opc = Alpha::STW; break; case MVT::i32: Opc = Alpha::STL; break; From alenhar2 at cs.uiuc.edu Tue Nov 22 15:45:31 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 22 Nov 2005 15:45:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/Reg2Mem.cpp Message-ID: <200511222145.PAA11428@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: Reg2Mem.cpp updated: 1.3 -> 1.4 --- Log message: turns out, demotion and invokes and critical edges don't mix --- Diffs of the changes: (+4 -0) Reg2Mem.cpp | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm/lib/Transforms/Scalar/Reg2Mem.cpp diff -u llvm/lib/Transforms/Scalar/Reg2Mem.cpp:1.3 llvm/lib/Transforms/Scalar/Reg2Mem.cpp:1.4 --- llvm/lib/Transforms/Scalar/Reg2Mem.cpp:1.3 Thu Nov 10 13:39:10 2005 +++ llvm/lib/Transforms/Scalar/Reg2Mem.cpp Tue Nov 22 15:45:19 2005 @@ -34,6 +34,10 @@ struct RegToMem : public FunctionPass { + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequiredID(BreakCriticalEdgesID); + } + bool valueEscapes(Instruction* i) { BasicBlock* bb = i->getParent(); for(Value::use_iterator ii = i->use_begin(), ie = i->use_end(); From alenhar2 at cs.uiuc.edu Tue Nov 22 16:14:36 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 22 Nov 2005 16:14:36 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/Scalar.h Message-ID: <200511222214.QAA22277@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: Scalar.h updated: 1.59 -> 1.60 --- Log message: Reg2Mem is something a pass may depend on, so allow that --- Diffs of the changes: (+1 -0) Scalar.h | 1 + 1 files changed, 1 insertion(+) Index: llvm/include/llvm/Transforms/Scalar.h diff -u llvm/include/llvm/Transforms/Scalar.h:1.59 llvm/include/llvm/Transforms/Scalar.h:1.60 --- llvm/include/llvm/Transforms/Scalar.h:1.59 Wed Nov 9 19:58:38 2005 +++ llvm/include/llvm/Transforms/Scalar.h Tue Nov 22 16:14:23 2005 @@ -168,6 +168,7 @@ // In basically undoes the PromoteMemoryToRegister pass to // make cfg hacking easier. FunctionPass *createDemoteRegisterToMemoryPass(); +extern const PassInfo *DemoteRegisterToMemoryID; //===----------------------------------------------------------------------===// // From alenhar2 at cs.uiuc.edu Tue Nov 22 16:14:36 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 22 Nov 2005 16:14:36 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/Reg2Mem.cpp Message-ID: <200511222214.QAA22276@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: Reg2Mem.cpp updated: 1.4 -> 1.5 --- Log message: Reg2Mem is something a pass may depend on, so allow that --- Diffs of the changes: (+1 -0) Reg2Mem.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm/lib/Transforms/Scalar/Reg2Mem.cpp diff -u llvm/lib/Transforms/Scalar/Reg2Mem.cpp:1.4 llvm/lib/Transforms/Scalar/Reg2Mem.cpp:1.5 --- llvm/lib/Transforms/Scalar/Reg2Mem.cpp:1.4 Tue Nov 22 15:45:19 2005 +++ llvm/lib/Transforms/Scalar/Reg2Mem.cpp Tue Nov 22 16:14:23 2005 @@ -80,6 +80,7 @@ // createDemoteRegisterToMemory - Provide an entry point to create this pass. // +const PassInfo *llvm::DemoteRegisterToMemoryID = X.getPassInfo(); FunctionPass *llvm::createDemoteRegisterToMemoryPass() { return new RegToMem(); } From natebegeman at mac.com Tue Nov 22 23:30:04 2005 From: natebegeman at mac.com (Nate Begeman) Date: Tue, 22 Nov 2005 23:30:04 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCInstrFormats.td PPCInstrInfo.td PPCRegisterInfo.td Message-ID: <200511230530.XAA24310@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCInstrFormats.td updated: 1.55 -> 1.56 PPCInstrInfo.td updated: 1.143 -> 1.144 PPCRegisterInfo.td updated: 1.20 -> 1.21 --- Log message: Some first bits of AltiVec stuff: Instruction Formats, Encodings, and Registers. Apologies to Jim if the scheduling info so far isn't accurate. There's a few more things like VRsave support that need to be finished up in my local tree before I can commit code that Does The Right Thing for turning 4 x float into the various altivec packed float instructions. --- Diffs of the changes: (+123 -1) PPCInstrFormats.td | 45 +++++++++++++++++++++++++++++++++++++++++++++ PPCInstrInfo.td | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ PPCRegisterInfo.td | 30 +++++++++++++++++++++++++++++- 3 files changed, 123 insertions(+), 1 deletion(-) Index: llvm/lib/Target/PowerPC/PPCInstrFormats.td diff -u llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.55 llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.56 --- llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.55 Tue Oct 25 15:58:43 2005 +++ llvm/lib/Target/PowerPC/PPCInstrFormats.td Tue Nov 22 23:29:52 2005 @@ -548,6 +548,51 @@ let Inst{31} = RC; } +// E-1 VA-Form +class VAForm_1 xo, dag OL, string asmstr, + InstrItinClass itin, list pattern> + : I<4, OL, asmstr, itin> { + bits<5> VD; + bits<5> VA; + bits<5> VB; + bits<5> VC; + + let Inst{6-10} = VD; + let Inst{11-15} = VA; + let Inst{16-20} = VB; + let Inst{21-25} = VC; + let Inst{26-31} = xo; +} + +// E-2 VX-Form +class VXForm_1 xo, dag OL, string asmstr, + InstrItinClass itin, list pattern> + : I<4, OL, asmstr, itin> { + bits<5> VD; + bits<5> VA; + bits<5> VB; + + let Inst{6-10} = VD; + let Inst{11-15} = VA; + let Inst{16-20} = VB; + let Inst{21-31} = xo; +} + +// E-4 VXR-Form +class VXRForm_1 xo, bit rc, dag OL, string asmstr, + InstrItinClass itin, list pattern> + : I<4, OL, asmstr, itin> { + bits<5> VD; + bits<5> VA; + bits<5> VB; + + let Inst{6-10} = VD; + let Inst{11-15} = VA; + let Inst{16-20} = VB; + let Inst{21} = rc; + let Inst{22-31} = xo; +} + //===----------------------------------------------------------------------===// def NoItin : InstrItinClass; class Pseudo pattern> Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.143 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.144 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.143 Thu Nov 17 13:16:08 2005 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Tue Nov 22 23:29:52 2005 @@ -360,6 +360,18 @@ "lwzx $dst, $base, $index", LdStGeneral>; def LDX : XForm_1<31, 21, (ops GPRC:$dst, GPRC:$base, GPRC:$index), "ldx $dst, $base, $index", LdStLD>, isPPC64; +def LVEBX: XForm_1<31, 7, (ops VRRC:$vD, GPRC:$base, GPRC:$rA), + "lvebx $vD, $base, $rA", LdStGeneral>; +def LVEHX: XForm_1<31, 39, (ops VRRC:$vD, GPRC:$base, GPRC:$rA), + "lvehx $vD, $base, $rA", LdStGeneral>; +def LVEWX: XForm_1<31, 71, (ops VRRC:$vD, GPRC:$base, GPRC:$rA), + "lvewx $vD, $base, $rA", LdStGeneral>; +def LVX : XForm_1<31, 103, (ops VRRC:$vD, GPRC:$base, GPRC:$rA), + "lvx $vD, $base, $rA", LdStGeneral>; +def LVSL : XForm_1<31, 6, (ops VRRC:$vD, GPRC:$base, GPRC:$rA), + "lvsl $vD, $base, $rA", LdStGeneral>; +def LVSR : XForm_1<31, 38, (ops VRRC:$vD, GPRC:$base, GPRC:$rA), + "lvsl $vD, $base, $rA", LdStGeneral>; } def NAND : XForm_6<31, 476, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB), "nand $rA, $rS, $rB", IntGeneral, @@ -431,6 +443,14 @@ "stdx $rS, $rA, $rB", LdStSTD>, isPPC64; def STDUX : XForm_8<31, 181, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB), "stdux $rS, $rA, $rB", LdStSTD>, isPPC64; +def STVEBX: XForm_8<31, 135, (ops VRRC:$rS, GPRC:$rA, GPRC:$rB), + "stvebx $rS, $rA, $rB", LdStGeneral>; +def STVEHX: XForm_8<31, 167, (ops VRRC:$rS, GPRC:$rA, GPRC:$rB), + "stvehx $rS, $rA, $rB", LdStGeneral>; +def STVEWX: XForm_8<31, 199, (ops VRRC:$rS, GPRC:$rA, GPRC:$rB), + "stvewx $rS, $rA, $rB", LdStGeneral>; +def STVX : XForm_8<31, 231, (ops VRRC:$rS, GPRC:$rA, GPRC:$rB), + "stvx $rS, $rA, $rB", LdStGeneral>; } def SRAWI : XForm_10<31, 824, (ops GPRC:$rA, GPRC:$rS, u5imm:$SH), "srawi $rA, $rS, $SH", IntShift, @@ -746,6 +766,35 @@ "rldicr $rA, $rS, $SH, $ME", IntRotateD, []>, isPPC64; +// VA-Form instructions. 3-input AltiVec ops. +def VMADDFP: VAForm_1<46, (ops VRRC:$vD, VRRC:$vA, VRRC:$vB, VRRC:$vC), + "vmaddfp $vD, $vA, $vB, $vC", VecFP, + []>; + +// VX-Form instructions. AltiVec arithmetic ops. +def VADDFP : VXForm_1<10, (ops VRRC:$vD, VRRC:$vA, VRRC:$vB), + "vaddfp $vD, $vA, $vB", VecFP, + []>; +def VADDUWM: VXForm_1<128, (ops VRRC:$vD, VRRC:$vA, VRRC:$vB), + "vadduwm $vD, $vA, $vB", VecGeneral, + []>; +def VAND : VXForm_1<1028, (ops VRRC:$vD, VRRC:$vA, VRRC:$vB), + "vand $vD, $vA, $vB", VecGeneral, + []>; +def VCFSX : VXForm_1<842, (ops VRRC:$vD, u5imm:$UIMM, VRRC:$vB), + "vcfsx $vD, $vB, $UIMM", VecFP, + []>; +def VCFUX : VXForm_1<778, (ops VRRC:$vD, u5imm:$UIMM, VRRC:$vB), + "vcfux $vD, $vB, $UIMM", VecFP, + []>; +def VOR : VXForm_1<1156, (ops VRRC:$vD, VRRC:$vA, VRRC:$vB), + "vor $vD, $vA, $vB", VecGeneral, + []>; +def VXOR : VXForm_1<1220, (ops VRRC:$vD, VRRC:$vA, VRRC:$vB), + "vxor $vD, $vA, $vB", VecGeneral, + []>; + + //===----------------------------------------------------------------------===// // PowerPC Instruction Patterns // Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.td diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.20 llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.21 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.20 Tue Oct 18 19:17:55 2005 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.td Tue Nov 22 23:29:52 2005 @@ -37,6 +37,11 @@ field bits<5> Num = num; } +// VR - One of the 32 128-bit vector registers +class VR num, string n> : PPCReg { + field bits<5> Num = num; +} + // CR - One of the 8 4-bit condition registers class CR num, string n> : PPCReg { field bits<5> Num = num; @@ -96,6 +101,23 @@ def F28 : FPR<28, "f28">; def F29 : FPR<29, "f29">; def F30 : FPR<30, "f30">; def F31 : FPR<31, "f31">; +// Floating-point registers +def V0 : VR< 0, "v0">; def V1 : VR< 1, "v1">; +def V2 : VR< 2, "v2">; def V3 : VR< 3, "v3">; +def V4 : VR< 4, "v4">; def V5 : VR< 5, "v5">; +def V6 : VR< 6, "v6">; def V7 : VR< 7, "v7">; +def V8 : VR< 8, "v8">; def V9 : VR< 9, "v9">; +def V10 : VR<10, "v10">; def V11 : VR<11, "v11">; +def V12 : VR<12, "v12">; def V13 : VR<13, "v13">; +def V14 : VR<14, "v14">; def V15 : VR<15, "v15">; +def V16 : VR<16, "v16">; def V17 : VR<17, "v17">; +def V18 : VR<18, "v18">; def V19 : VR<19, "v19">; +def V20 : VR<20, "v20">; def V21 : VR<21, "v21">; +def V22 : VR<22, "v22">; def V23 : VR<23, "v23">; +def V24 : VR<24, "v24">; def V25 : VR<25, "v25">; +def V26 : VR<26, "v26">; def V27 : VR<27, "v27">; +def V28 : VR<28, "v28">; def V29 : VR<29, "v29">; +def V30 : VR<30, "v30">; def V31 : VR<31, "v31">; // Condition registers def CR0 : CR<0, "cr0">; def CR1 : CR<1, "cr1">; @@ -104,9 +126,12 @@ def CR6 : CR<6, "cr6">; def CR7 : CR<7, "cr7">; // Link register -def LR : SPR<2, "lr">; +// FIXME: encode actual spr numbers here +def LR : SPR<2, "lr">; // Count register def CTR : SPR<3, "ctr">; +// VRsave register +def VRSAVE: SPR<4, "VRsave">; /// Register classes // Allocate volatiles first @@ -167,5 +192,8 @@ F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30, F31]>; +def VRRC : RegisterClass<"PPC", i128, 128, [V0, V1, V2, V3, V4, V5, V6, V7, V8, + V9, V10, V11, V12, V13, V14, V15, V16, V17, V18, V19, V20, V21, V22, V23, + V24, V25, V26, V27, V28, V29, V30, V31]>; def CRRC : RegisterClass<"PPC", i32, 32, [CR0, CR1, CR5, CR6, CR7, CR2, CR3, CR4]>; From duraid at octopus.com.au Fri Nov 25 01:49:37 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Fri, 25 Nov 2005 01:49:37 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp Message-ID: <200511250749.BAA25147@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64ISelDAGToDAG.cpp updated: 1.11 -> 1.12 --- Log message: add support for dynamic_stackalloc to the dag isel (thanks andrew ;) next up: support argument passing in memory, not just registers --- Diffs of the changes: (+31 -3) IA64ISelDAGToDAG.cpp | 34 +++++++++++++++++++++++++++++++--- 1 files changed, 31 insertions(+), 3 deletions(-) Index: llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp diff -u llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.11 llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.12 --- llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.11 Mon Nov 21 08:14:54 2005 +++ llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp Fri Nov 25 01:49:25 2005 @@ -536,9 +536,37 @@ case ISD::SREM: case ISD::UREM: return SelectDIV(Op); -/* todo: - * case ISD::DYNAMIC_STACKALLOC: -*/ + case ISD::DYNAMIC_STACKALLOC: { + if (!isa(N->getOperand(2)) || + cast(N->getOperand(2))->getValue() != 0) { + std::cerr << "Cannot allocate stack object with greater alignment than" + << " the stack alignment yet!"; + abort(); + } + + SDOperand Chain = Select(N->getOperand(0)); + SDOperand Amt = Select(N->getOperand(1)); + SDOperand Reg = CurDAG->getRegister(IA64::r12, MVT::i64); + SDOperand Val = CurDAG->getCopyFromReg(Chain, IA64::r12, MVT::i64); + Chain = Val.getValue(1); + + // Subtract the amount (guaranteed to be a multiple of the stack alignment) + // from the stack pointer, giving us the result pointer. + SDOperand Result = Select(CurDAG->getNode(ISD::SUB, MVT::i64, Val, Amt)); + + // Copy this result back into r12. + Chain = CurDAG->getNode(ISD::CopyToReg, MVT::Other, Chain, Reg, Result); + + // Copy this result back out of r12 to make sure we're not using the stack + // space without decrementing the stack pointer. + Result = CurDAG->getCopyFromReg(Chain, IA64::r12, MVT::i64); + + // Finally, replace the DYNAMIC_STACKALLOC with the copyfromreg. + CodeGenMap[Op.getValue(0)] = Result; + CodeGenMap[Op.getValue(1)] = Result.getValue(1); + return SDOperand(Result.Val, Op.ResNo); + } + case ISD::ConstantFP: { SDOperand Chain = CurDAG->getEntryNode(); // this is a constant, so.. From alenhar2 at cs.uiuc.edu Fri Nov 25 10:05:07 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Fri, 25 Nov 2005 10:05:07 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/Reg2Mem.cpp Message-ID: <200511251605.KAA20585@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: Reg2Mem.cpp updated: 1.5 -> 1.6 --- Log message: since reg2mem requires it, might as well mention that it preserves it --- Diffs of the changes: (+1 -0) Reg2Mem.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm/lib/Transforms/Scalar/Reg2Mem.cpp diff -u llvm/lib/Transforms/Scalar/Reg2Mem.cpp:1.5 llvm/lib/Transforms/Scalar/Reg2Mem.cpp:1.6 --- llvm/lib/Transforms/Scalar/Reg2Mem.cpp:1.5 Tue Nov 22 16:14:23 2005 +++ llvm/lib/Transforms/Scalar/Reg2Mem.cpp Fri Nov 25 10:04:54 2005 @@ -36,6 +36,7 @@ virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequiredID(BreakCriticalEdgesID); + AU.addPreservedID(BreakCriticalEdgesID); } bool valueEscapes(Instruction* i) { From natebegeman at mac.com Sat Nov 26 16:39:46 2005 From: natebegeman at mac.com (Nate Begeman) Date: Sat, 26 Nov 2005 16:39:46 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCRegisterInfo.td PPCInstrInfo.td PPCInstrFormats.td Message-ID: <200511262239.QAA19860@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCRegisterInfo.td updated: 1.21 -> 1.22 PPCInstrInfo.td updated: 1.144 -> 1.145 PPCInstrFormats.td updated: 1.56 -> 1.57 --- Log message: Small tweaks noticed while on the plane. --- Diffs of the changes: (+10 -5) PPCInstrFormats.td | 6 ++++++ PPCInstrInfo.td | 7 +++---- PPCRegisterInfo.td | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.td diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.21 llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.22 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.21 Tue Nov 22 23:29:52 2005 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.td Sat Nov 26 16:39:34 2005 @@ -101,7 +101,7 @@ def F28 : FPR<28, "f28">; def F29 : FPR<29, "f29">; def F30 : FPR<30, "f30">; def F31 : FPR<31, "f31">; -// Floating-point registers +// Vector registers def V0 : VR< 0, "v0">; def V1 : VR< 1, "v1">; def V2 : VR< 2, "v2">; def V3 : VR< 3, "v3">; def V4 : VR< 4, "v4">; def V5 : VR< 5, "v5">; Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.144 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.145 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.144 Tue Nov 22 23:29:52 2005 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Sat Nov 26 16:39:34 2005 @@ -464,9 +464,9 @@ def EXTSH : XForm_11<31, 922, (ops GPRC:$rA, GPRC:$rS), "extsh $rA, $rS", IntGeneral, [(set GPRC:$rA, (sext_inreg GPRC:$rS, i16))]>; -def EXTSW : XForm_11<31, 986, (ops GPRC:$rA, GPRC:$rS), - "extsw $rA, $rS", IntRotateD, - []>, isPPC64; +def EXTSW : XForm_11<31, 986, (ops G8RC:$rA, G8RC:$rS), + "extsw $rA, $rS", IntGeneral, + [(set G8RC:$rA, (sext_inreg G8RC:$rS, i32))]>, isPPC64; def CMP : XForm_16<31, 0, (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB), "cmp $crD, $long, $rA, $rB", IntCompare>; def CMPL : XForm_16<31, 32, (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB), @@ -794,7 +794,6 @@ "vxor $vD, $vA, $vB", VecGeneral, []>; - //===----------------------------------------------------------------------===// // PowerPC Instruction Patterns // Index: llvm/lib/Target/PowerPC/PPCInstrFormats.td diff -u llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.56 llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.57 --- llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.56 Tue Nov 22 23:29:52 2005 +++ llvm/lib/Target/PowerPC/PPCInstrFormats.td Sat Nov 26 16:39:34 2005 @@ -556,6 +556,8 @@ bits<5> VA; bits<5> VB; bits<5> VC; + + let Pattern = pattern; let Inst{6-10} = VD; let Inst{11-15} = VA; @@ -572,6 +574,8 @@ bits<5> VA; bits<5> VB; + let Pattern = pattern; + let Inst{6-10} = VD; let Inst{11-15} = VA; let Inst{16-20} = VB; @@ -586,6 +590,8 @@ bits<5> VA; bits<5> VB; + let Pattern = pattern; + let Inst{6-10} = VD; let Inst{11-15} = VA; let Inst{16-20} = VB; From alenhar2 at cs.uiuc.edu Sun Nov 27 18:58:22 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sun, 27 Nov 2005 18:58:22 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/Instrumentation.h LinkAllPasses.h Message-ID: <200511280058.SAA27864@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: Instrumentation.h updated: 1.8 -> 1.9 LinkAllPasses.h updated: 1.25 -> 1.26 --- Log message: Random sampling (aka Arnold and Ryder) profiling. This is still preliminary, but it works on spec on x86 and alpha. The idea is to allow profiling passes to remember what profiling they inserted, then a random sampling framework is inserted which consists of duplicated basic blocks (without profiling), such that at each backedge in the program and entry into every function, the framework chooses whether to use the instrumented code or the instrumentation free code. The goal of such a framework is to make it reasonably cheap to do random sampling of very expensive profiling products (such as load-value profiling). The code is organized into 3 parts (2 passes) 1) a linked set of profiling passes, which implement an analysis group (linked, like alias analysis are). These insert profiling into the program, and remember what they inserted, so that at a later time they can be queried about any instruction. 2) a pass that handles inserting the random sampling framework. This also has options to control how random samples are choosen. Currently implemented are Global counters, register allocated global counters, and read cycle counter (see? there was a reason for it). The profiling passes are almost identical to the existing ones (block, function, and null profiling is supported right now), and they are valid passes without the sampling framework (hence the existing passes can be unified with the new ones, not done yet). Some things are a bit ugly still, but that should be fixed up soon enough. Other todo? making the counter values not "magic 2^16 -1" values, but dynamically choosable. --- Diffs of the changes: (+12 -0) Instrumentation.h | 7 +++++++ LinkAllPasses.h | 5 +++++ 2 files changed, 12 insertions(+) Index: llvm/include/llvm/Transforms/Instrumentation.h diff -u llvm/include/llvm/Transforms/Instrumentation.h:1.8 llvm/include/llvm/Transforms/Instrumentation.h:1.9 --- llvm/include/llvm/Transforms/Instrumentation.h:1.8 Thu Apr 21 15:57:32 2005 +++ llvm/include/llvm/Transforms/Instrumentation.h Sun Nov 27 18:58:09 2005 @@ -43,6 +43,13 @@ // Reoptimizer support pass: insert counting of execute paths instrumentation FunctionPass *createProfilePathsPass(); +// Random Sampling Profiling Framework +ModulePass* createBlockProfilerRSPass(); +ModulePass* createFunctionProfilerRSPass(); +ModulePass* createNullProfilerRSPass(); +FunctionPass* createRSProfilingPass(); + + //===----------------------------------------------------------------------===// // Support for inserting LLVM code to print values at basic block and function // exits. Index: llvm/include/llvm/Transforms/LinkAllPasses.h diff -u llvm/include/llvm/Transforms/LinkAllPasses.h:1.25 llvm/include/llvm/Transforms/LinkAllPasses.h:1.26 --- llvm/include/llvm/Transforms/LinkAllPasses.h:1.25 Wed Nov 9 20:07:45 2005 +++ llvm/include/llvm/Transforms/LinkAllPasses.h Sun Nov 27 18:58:09 2005 @@ -106,6 +106,11 @@ (void) llvm::createTraceValuesPassForFunction(); (void) llvm::createUnifyFunctionExitNodesPass(); (void) llvm::createCondPropagationPass(); + (void) llvm::createBlockProfilerRSPass(); + (void) llvm::createFunctionProfilerRSPass(); + (void) llvm::createNullProfilerRSPass(); + (void) llvm::createRSProfilingPass(); + } } ForcePassLinking; }; From alenhar2 at cs.uiuc.edu Sun Nov 27 18:58:21 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sun, 27 Nov 2005 18:58:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/RSProfiling.cpp RSProfiling.h Message-ID: <200511280058.SAA27858@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: RSProfiling.cpp added (r1.1) RSProfiling.h added (r1.1) --- Log message: Random sampling (aka Arnold and Ryder) profiling. This is still preliminary, but it works on spec on x86 and alpha. The idea is to allow profiling passes to remember what profiling they inserted, then a random sampling framework is inserted which consists of duplicated basic blocks (without profiling), such that at each backedge in the program and entry into every function, the framework chooses whether to use the instrumented code or the instrumentation free code. The goal of such a framework is to make it reasonably cheap to do random sampling of very expensive profiling products (such as load-value profiling). The code is organized into 3 parts (2 passes) 1) a linked set of profiling passes, which implement an analysis group (linked, like alias analysis are). These insert profiling into the program, and remember what they inserted, so that at a later time they can be queried about any instruction. 2) a pass that handles inserting the random sampling framework. This also has options to control how random samples are choosen. Currently implemented are Global counters, register allocated global counters, and read cycle counter (see? there was a reason for it). The profiling passes are almost identical to the existing ones (block, function, and null profiling is supported right now), and they are valid passes without the sampling framework (hence the existing passes can be unified with the new ones, not done yet). Some things are a bit ugly still, but that should be fixed up soon enough. Other todo? making the counter values not "magic 2^16 -1" values, but dynamically choosable. --- Diffs of the changes: (+730 -0) RSProfiling.cpp | 702 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ RSProfiling.h | 28 ++ 2 files changed, 730 insertions(+) Index: llvm/lib/Transforms/Instrumentation/RSProfiling.cpp diff -c /dev/null llvm/lib/Transforms/Instrumentation/RSProfiling.cpp:1.1 *** /dev/null Sun Nov 27 18:58:19 2005 --- llvm/lib/Transforms/Instrumentation/RSProfiling.cpp Sun Nov 27 18:58:09 2005 *************** *** 0 **** --- 1,702 ---- + //===- RSProfiling.cpp - Various profiling using random sampling ----------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // These passes implement a random sampling based profiling. Different methods + // of choosing when to sample are supported, as well as different types of + // profiling. This is done as two passes. The first is a sequence of profiling + // passes which insert profiling into the program, and remember what they inserted. + // The second stage duplicates all instructions in a function, ignoring the + // profiling code, then connects the two versions togeather at the entry and at + // backedges. At each connection point a choice is made as to whether to jump + // to the profiled code (take a sample) or execute the unprofiled code. + // + // It is highly recommeneded that after this pass one runs mem2reg and adce + // (instcombine load-vn gdce dse also are good to run afterwards) + // + // This design is intended to make the profiling passes independent of the RS + // framework, but any profiling pass that implements the RSProfiling interface + // is compatible with the rs framework (and thus can be sampled) + // + // TODO: obviously the block and function profiling are almost identical to the + // existing ones, so they can be unified (esp since these passes are valid + // without the rs framework). + // TODO: Fix choice code so that frequency is not hard coded + // + //===----------------------------------------------------------------------===// + + #include "llvm/Pass.h" + #include "llvm/Function.h" + #include "llvm/Module.h" + #include "llvm/BasicBlock.h" + #include "llvm/Instructions.h" + #include "llvm/Constants.h" + #include "llvm/DerivedTypes.h" + #include "llvm/Transforms/Scalar.h" + #include "llvm/Transforms/Utils/BasicBlockUtils.h" + #include "llvm/ADT/Statistic.h" + #include "llvm/Support/CommandLine.h" + #include "llvm/Support/Debug.h" + #include "llvm/Transforms/Instrumentation.h" + #include "ProfilingUtils.h" + #include "RSProfiling.h" + + #include + #include + #include + #include + #include + + using namespace llvm; + + namespace { + Statistic<> NumBackEdges("bedge", "Number of BackEdges"); + + enum RandomMeth { + GBV, GBVO, HOSTCC + }; + + cl::opt RandomMethod("profile-randomness", + cl::desc("How to randomly choose to profile:"), + cl::values( + clEnumValN(GBV, "global", "global counter"), + clEnumValN(GBVO, "ra_global", "register allocated global counter"), + clEnumValN(HOSTCC, "rdcc", "cycle counter"), + clEnumValEnd)); + + + class FunctionProfilerRS : public RSProfilers { + bool runOnModule(Module &M); + }; + + class BlockProfilerRS : public RSProfilers { + bool runOnModule(Module &M); + }; + + class NullProfilerRS : public RSProfilers { + public: + bool isProfiling(Value* v) { + return false; + } + bool runOnModule(Module &M) { + return false; + } + void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + } + }; + + static RegisterAnalysisGroup A("Profiling passes"); + static RegisterOpt NP("insert-null-profiling-rs", + "Measure profiling framework overhead"); + static RegisterAnalysisGroup NPT; + static RegisterOpt BBP("insert-block-profiling-rs", + "Add block count instrumentation"); + static RegisterAnalysisGroup BBPT; + static RegisterOpt FP("insert-function-profiling-rs", + "Add function count instrumentation"); + static RegisterAnalysisGroup FPT; + + + //Something that chooses how to sample + class Chooser { + public: + virtual void ProcessChoicePoint(BasicBlock*) = 0; + virtual void PrepFunction(Function*) = 0; + virtual ~Chooser() {} + }; + + //Things that implement sampling policies + class GlobalRandomCounter : public Chooser { + GlobalVariable* Counter; + Value* ResetValue; + const Type* T; + public: + GlobalRandomCounter(Module& M, const Type* t, uint64_t resetval); + virtual ~GlobalRandomCounter(); + virtual void PrepFunction(Function* F); + virtual void ProcessChoicePoint(BasicBlock* bb); + }; + + class GlobalRandomCounterOpt : public Chooser { + GlobalVariable* Counter; + Value* ResetValue; + AllocaInst* AI; + const Type* T; + public: + GlobalRandomCounterOpt(Module& M, const Type* t, uint64_t resetval); + virtual ~GlobalRandomCounterOpt(); + virtual void PrepFunction(Function* F); + virtual void ProcessChoicePoint(BasicBlock* bb); + }; + + class CycleCounter : public Chooser { + uint64_t rm; + Function* F; + public: + CycleCounter(Module& m, uint64_t resetmask); + virtual ~CycleCounter(); + virtual void PrepFunction(Function* F); + virtual void ProcessChoicePoint(BasicBlock* bb); + }; + + + struct ProfilerRS : public FunctionPass { + std::map TransCache; + std::set ChoicePoints; + Chooser* c; + + Value* Translate(Value* v); + void Duplicate(Function& F, RSProfilers& LI); + void ProcessBackEdge(BasicBlock* src, BasicBlock* dst, Function& F); + bool runOnFunction(Function& F); + bool doInitialization(Module &M); + virtual void getAnalysisUsage(AnalysisUsage &AU) const; + }; + + RegisterOpt X("insert-rs-profiling-framework", + "Insert random sampling instrumentation framework"); + }; + + //Local utilities + static void ReplacePhiPred(BasicBlock* btarget, + BasicBlock* bold, BasicBlock* bnew); + + static void CollapsePhi(BasicBlock* btarget, BasicBlock* bsrc); + + template + static void recBackEdge(BasicBlock* bb, T& BackEdges, + std::map& color, + std::map& depth, + std::map& finish, + int& time); + + //find the back edges and where they go to + template + static void getBackEdges(Function& F, T& BackEdges); + + + /////////////////////////////////////// + // Methods of choosing when to profile + /////////////////////////////////////// + + GlobalRandomCounter::GlobalRandomCounter(Module& M, const Type* t, + uint64_t resetval) : T(t) { + Counter = new GlobalVariable(T, false, GlobalValue::InternalLinkage, + ConstantUInt::get(T, resetval), + "RandomSteeringCounter", &M); + ResetValue = ConstantUInt::get(T, resetval); + } + + GlobalRandomCounter::~GlobalRandomCounter() {} + + void GlobalRandomCounter::PrepFunction(Function* F) {} + + void GlobalRandomCounter::ProcessChoicePoint(BasicBlock* bb) { + BranchInst* t = cast(bb->getTerminator()); + + //decrement counter + LoadInst* l = new LoadInst(Counter, "counter", t); + + SetCondInst* s = new SetCondInst(Instruction::SetEQ, l, ConstantUInt::get(T, 0), + "countercc", t); + Value* nv = BinaryOperator::create(Instruction::Sub, l, + ConstantInt::get(T, 1), + "counternew", t); + new StoreInst(nv, Counter, t); + t->setCondition(s); + + //reset counter + BasicBlock* oldnext = t->getSuccessor(0); + BasicBlock* resetblock = new BasicBlock("reset", oldnext->getParent(), oldnext); + TerminatorInst* t2 = new BranchInst(oldnext, resetblock); + t->setSuccessor(0, resetblock); + new StoreInst(ResetValue, Counter, t2); + ReplacePhiPred(oldnext, bb, resetblock); + } + + GlobalRandomCounterOpt::GlobalRandomCounterOpt(Module& M, const Type* t, + uint64_t resetval) + : AI(0), T(t) { + Counter = new GlobalVariable(T, false, GlobalValue::InternalLinkage, + ConstantUInt::get(T, resetval), + "RandomSteeringCounter", &M); + ResetValue = ConstantUInt::get(T, resetval); + } + + GlobalRandomCounterOpt::~GlobalRandomCounterOpt() {} + + void GlobalRandomCounterOpt::PrepFunction(Function* F) { + //make a local temporary to cache the global + BasicBlock& bb = F->getEntryBlock(); + AI = new AllocaInst(T, 0, "localcounter", bb.begin()); + LoadInst* l = new LoadInst(Counter, "counterload", AI->getNext()); + new StoreInst(l, AI, l->getNext()); + + //modify all functions and return values + for(Function::iterator fib = F->begin(), fie = F->end(); + fib != fie; ++fib) + for(BasicBlock::iterator bib = fib->begin(), bie = fib->end(); + bib != bie; ++bib) + if (isa(&*bib)) { + LoadInst* l = new LoadInst(AI, "counter", bib); + new StoreInst(l, Counter, bib); + l = new LoadInst(Counter, "counter", bib->getNext()); + new StoreInst(l, AI, l->getNext()); + } else if (isa(&*bib)) { + LoadInst* l = new LoadInst(AI, "counter", bib); + new StoreInst(l, Counter, bib); + + BasicBlock* bb = cast(&*bib)->getNormalDest(); + Instruction* i = bb->begin(); + while (isa(i)) i = i->getNext(); + l = new LoadInst(Counter, "counter", i); + + bb = cast(&*bib)->getUnwindDest(); + i = bb->begin(); + while (isa(i)) i = i->getNext(); + l = new LoadInst(Counter, "counter", i); + new StoreInst(l, AI, l->getNext()); + } else if (isa(&*bib) || isa(&*bib)) { + LoadInst* l = new LoadInst(AI, "counter", bib); + new StoreInst(l, Counter, bib); + } + } + + void GlobalRandomCounterOpt::ProcessChoicePoint(BasicBlock* bb) { + BranchInst* t = cast(bb->getTerminator()); + + //decrement counter + LoadInst* l = new LoadInst(AI, "counter", t); + + SetCondInst* s = new SetCondInst(Instruction::SetEQ, l, ConstantUInt::get(T, 0), + "countercc", t); + Value* nv = BinaryOperator::create(Instruction::Sub, l, + ConstantInt::get(T, 1), + "counternew", t); + new StoreInst(nv, AI, t); + t->setCondition(s); + + //reset counter + BasicBlock* oldnext = t->getSuccessor(0); + BasicBlock* resetblock = new BasicBlock("reset", oldnext->getParent(), oldnext); + TerminatorInst* t2 = new BranchInst(oldnext, resetblock); + t->setSuccessor(0, resetblock); + new StoreInst(ResetValue, AI, t2); + ReplacePhiPred(oldnext, bb, resetblock); + } + + + CycleCounter::CycleCounter(Module& m, uint64_t resetmask) : rm(resetmask) { + F = m.getOrInsertFunction("llvm.readcyclecounter", Type::ULongTy, NULL); + } + + CycleCounter::~CycleCounter() {} + + void CycleCounter::PrepFunction(Function* F) {} + + void CycleCounter::ProcessChoicePoint(BasicBlock* bb) { + BranchInst* t = cast(bb->getTerminator()); + + CallInst* c = new CallInst(F, "rdcc", t); + BinaryOperator* b = BinaryOperator::create(Instruction::And, c, ConstantUInt::get(Type::ULongTy, rm), "mrdcc", t); + + SetCondInst* s = new SetCondInst(Instruction::SetEQ, b, ConstantUInt::get(Type::ULongTy, 0), + "mrdccc", t); + t->setCondition(s); + } + + /////////////////////////////////////// + // Profiling: + /////////////////////////////////////// + bool RSProfilers::isProfiling(Value* v) { + if (profcode.find(v) != profcode.end()) + return true; + //else + RSProfilers& LI = getAnalysis(); + return LI.isProfiling(v); + } + + void RSProfilers::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum, + GlobalValue *CounterArray) { + // Insert the increment after any alloca or PHI instructions... + BasicBlock::iterator InsertPos = BB->begin(); + while (isa(InsertPos) || isa(InsertPos)) + ++InsertPos; + + // Create the getelementptr constant expression + std::vector Indices(2); + Indices[0] = Constant::getNullValue(Type::IntTy); + Indices[1] = ConstantSInt::get(Type::IntTy, CounterNum); + Constant *ElementPtr = ConstantExpr::getGetElementPtr(CounterArray, Indices); + + // Load, increment and store the value back. + Value *OldVal = new LoadInst(ElementPtr, "OldCounter", InsertPos); + profcode.insert(OldVal); + Value *NewVal = BinaryOperator::create(Instruction::Add, OldVal, + ConstantInt::get(Type::UIntTy, 1), + "NewCounter", InsertPos); + profcode.insert(NewVal); + profcode.insert(new StoreInst(NewVal, ElementPtr, InsertPos)); + } + + void RSProfilers::getAnalysisUsage(AnalysisUsage &AU) const { + //grab any outstanding profiler, or get the null one + AU.addRequired(); + } + + bool FunctionProfilerRS::runOnModule(Module &M) { + Function *Main = M.getMainFunction(); + if (Main == 0) { + std::cerr << "WARNING: cannot insert function profiling into a module" + << " with no main function!\n"; + return false; // No main, no instrumentation! + } + + unsigned NumFunctions = 0; + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + if (!I->isExternal()) + ++NumFunctions; + + const Type *ATy = ArrayType::get(Type::UIntTy, NumFunctions); + GlobalVariable *Counters = + new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, + Constant::getNullValue(ATy), "FuncProfCounters", &M); + + // Instrument all of the functions... + unsigned i = 0; + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + if (!I->isExternal()) + // Insert counter at the start of the function + IncrementCounterInBlock(I->begin(), i++, Counters); + + // Add the initialization call to main. + InsertProfilingInitCall(Main, "llvm_start_func_profiling", Counters); + return true; + } + + bool BlockProfilerRS::runOnModule(Module &M) { + Function *Main = M.getMainFunction(); + if (Main == 0) { + std::cerr << "WARNING: cannot insert block profiling into a module" + << " with no main function!\n"; + return false; // No main, no instrumentation! + } + + unsigned NumBlocks = 0; + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + NumBlocks += I->size(); + + const Type *ATy = ArrayType::get(Type::UIntTy, NumBlocks); + GlobalVariable *Counters = + new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, + Constant::getNullValue(ATy), "BlockProfCounters", &M); + + // Instrument all of the blocks... + unsigned i = 0; + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + for (Function::iterator BB = I->begin(), E = I->end(); BB != E; ++BB) + // Insert counter at the start of the block + IncrementCounterInBlock(BB, i++, Counters); + + // Add the initialization call to main. + InsertProfilingInitCall(Main, "llvm_start_block_profiling", Counters); + return true; + } + + /////////////////////////////////////// + // RS Framework + /////////////////////////////////////// + + Value* ProfilerRS::Translate(Value* v) { + if(TransCache[v]) + return TransCache[v]; + + if (BasicBlock* bb = dyn_cast(v)) { + if (bb == &bb->getParent()->getEntryBlock()) + TransCache[bb] = bb; //don't translate entry block + else + TransCache[bb] = new BasicBlock("dup_" + bb->getName(), bb->getParent(), NULL); + return TransCache[bb]; + } else if (Instruction* i = dyn_cast(v)) { + //we have already translated this + //do not translate entry block allocas + if(&i->getParent()->getParent()->getEntryBlock() == i->getParent()) { + TransCache[i] = i; + return i; + } else { + //translate this + Instruction* i2 = i->clone(); + if (i->hasName()) + i2->setName("dup_" + i->getName()); + TransCache[i] = i2; + //NumNewInst++; + for (unsigned x = 0; x < i2->getNumOperands(); ++x) + i2->setOperand(x, Translate(i2->getOperand(x))); + return i2; + } + } else if (isa(v) || isa(v) || isa(v)) { + TransCache[v] = v; + return v; + } + assert(0 && "Value not handled"); + } + + void ProfilerRS::Duplicate(Function& F, RSProfilers& LI) + { + //perform a breadth first search, building up a duplicate of the code + std::queue worklist; + std::set seen; + + //This loop ensures proper BB order, to help performance + for (Function::iterator fib = F.begin(), fie = F.end(); fib != fie; ++fib) + worklist.push(fib); + while (!worklist.empty()) { + Translate(worklist.front()); + worklist.pop(); + } + + //remember than reg2mem created a new entry block we don't want to duplicate + worklist.push(F.getEntryBlock().getTerminator()->getSuccessor(0)); + seen.insert(&F.getEntryBlock()); + + while (!worklist.empty()) { + BasicBlock* bb = worklist.front(); + worklist.pop(); + if(seen.find(bb) == seen.end()) { + BasicBlock* bbtarget = cast(Translate(bb)); + BasicBlock::InstListType& instlist = bbtarget->getInstList(); + for (BasicBlock::iterator iib = bb->begin(), iie = bb->end(); + iib != iie; ++iib) { + //NumOldInst++; + if (!LI.isProfiling(&*iib)) { + Instruction* i = cast(Translate(iib)); + instlist.insert(bbtarget->end(), i); + } + } + //updated search state; + seen.insert(bb); + TerminatorInst* ti = bb->getTerminator(); + for (unsigned x = 0; x < ti->getNumSuccessors(); ++x) { + BasicBlock* bbs = ti->getSuccessor(x); + if (seen.find(bbs) == seen.end()) { + worklist.push(bbs); + } + } + } + } + } + + void ProfilerRS::ProcessBackEdge(BasicBlock* src, BasicBlock* dst, Function& F) { + //given a backedge from B -> A, and translations A' and B', + //a: insert C and C' + //b: add branches in C to A and A' and in C' to A and A' + //c: mod terminators at B, replace A with C + //d: mod terminators at B', replace A' with C' + //e: mod phis at A for pred B to be pred C + // if multiple entries, simplify to one + //f: mod phis at A' for pred B' to be pred C' + // if multiple entries, simplify to one + //g: for all phis at A with pred C using x + // add in edge from C' using x' + // add in edge from C using x in A' + + //a: + BasicBlock* bbC = new BasicBlock("choice", &F, src->getNext() ); + //ChoicePoints.insert(bbC); + BasicBlock* bbCp = new BasicBlock("choice", &F, cast(Translate(src))->getNext() ); + ChoicePoints.insert(bbCp); + + //b: + //new BranchInst(dst, cast(Translate(dst)), ConstantBool::get(true), bbC); + new BranchInst(cast(Translate(dst)), bbC); + new BranchInst(dst, cast(Translate(dst)), ConstantBool::get(true), bbCp); + //c: + { + TerminatorInst* iB = src->getTerminator(); + for (unsigned x = 0; x < iB->getNumSuccessors(); ++x) + if (iB->getSuccessor(x) == dst) + iB->setSuccessor(x, bbC); + } + //d: + { + TerminatorInst* iBp = cast(Translate(src->getTerminator())); + for (unsigned x = 0; x < iBp->getNumSuccessors(); ++x) + if (iBp->getSuccessor(x) == cast(Translate(dst))) + iBp->setSuccessor(x, bbCp); + } + //e: + ReplacePhiPred(dst, src, bbC); + //src could be a switch, in which case we are replacing several edges with one + //thus collapse those edges int the Phi + CollapsePhi(dst, bbC); + //f: + ReplacePhiPred(cast(Translate(dst)),cast(Translate(src)),bbCp); + CollapsePhi(cast(Translate(dst)), bbCp); + //g: + for(BasicBlock::iterator ib = dst->begin(), ie = dst->end(); ib != ie; + ++ib) + if (PHINode* phi = dyn_cast(&*ib)) { + for(unsigned x = 0; x < phi->getNumIncomingValues(); ++x) + if(bbC == phi->getIncomingBlock(x)) { + phi->addIncoming(Translate(phi->getIncomingValue(x)), bbCp); + cast(Translate(phi))->addIncoming(phi->getIncomingValue(x), bbC); + } + phi->removeIncomingValue(bbC); + } + } + + bool ProfilerRS::runOnFunction(Function& F) { + if (!F.isExternal()) { + std::set > BackEdges; + RSProfilers& LI = getAnalysis(); + + getBackEdges(F, BackEdges); + DEBUG( + for (std::set >::iterator ii = BackEdges.begin(); + ii != BackEdges.end(); ++ii) + std::cerr << ii->first->getName() << " -> " << ii->second->getName() << "\n"; + ); + Duplicate(F, LI); + //assume that stuff worked. now connect the duplicated basic blocks + //with the originals in such a way as to preserve ssa. yuk! + for (std::set >::iterator ib = BackEdges.begin(), + ie = BackEdges.end(); ib != ie; ++ib) + ProcessBackEdge(ib->first, ib->second, F); + + //oh, and add the edge from the reg2mem created entry node to the duplicated second node + TerminatorInst* T = F.getEntryBlock().getTerminator(); + ReplaceInstWithInst(T, new BranchInst(T->getSuccessor(0), + cast(Translate(T->getSuccessor(0))), + ConstantBool::get(true))); + + //do whatever is needed now that the function is duplicated + c->PrepFunction(&F); + + //add entry node to choice points + ChoicePoints.insert(&F.getEntryBlock()); + + for (std::set::iterator ii = ChoicePoints.begin(), ie = ChoicePoints.end(); + ii != ie; ++ii) + c->ProcessChoicePoint(*ii); + + ChoicePoints.clear(); + TransCache.clear(); + + return true; + } + return false; + } + + bool ProfilerRS::doInitialization(Module &M) { + switch (RandomMethod) { + case GBV: + c = new GlobalRandomCounter(M, Type::UIntTy, (1 << 14) - 1); + break; + case GBVO: + c = new GlobalRandomCounterOpt(M, Type::UIntTy, (1 << 14) - 1); + break; + case HOSTCC: + c = new CycleCounter(M, (1 << 14) - 1); + break; + }; + return true; + } + + void ProfilerRS::getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); + AU.addRequiredID(DemoteRegisterToMemoryID); + } + + /////////////////////////////////////// + // Utilities: + /////////////////////////////////////// + static void ReplacePhiPred(BasicBlock* btarget, + BasicBlock* bold, BasicBlock* bnew) { + for(BasicBlock::iterator ib = btarget->begin(), ie = btarget->end(); + ib != ie; ++ib) + if (PHINode* phi = dyn_cast(&*ib)) { + for(unsigned x = 0; x < phi->getNumIncomingValues(); ++x) + if(bold == phi->getIncomingBlock(x)) + phi->setIncomingBlock(x, bnew); + } + } + + static void CollapsePhi(BasicBlock* btarget, BasicBlock* bsrc) { + for(BasicBlock::iterator ib = btarget->begin(), ie = btarget->end(); + ib != ie; ++ib) + if (PHINode* phi = dyn_cast(&*ib)) { + unsigned total = phi->getNumIncomingValues(); + std::map counter; + for(unsigned i = 0; i < phi->getNumIncomingValues(); ) { + if (counter[phi->getIncomingBlock(i)]) { + assert (phi->getIncomingValue(i) == counter[phi->getIncomingBlock(i)]); + phi->removeIncomingValue(i, false); + } else { + counter[phi->getIncomingBlock(i)] = phi->getIncomingValue(i); + ++i; + } + } + } + } + + template + static void recBackEdge(BasicBlock* bb, T& BackEdges, + std::map& color, + std::map& depth, + std::map& finish, + int& time) + { + color[bb] = 1; + ++time; + depth[bb] = time; + TerminatorInst* t= bb->getTerminator(); + for(unsigned i = 0; i < t->getNumSuccessors(); ++i) { + BasicBlock* bbnew = t->getSuccessor(i); + if (color[bbnew] == 0) + recBackEdge(bbnew, BackEdges, color, depth, finish, time); + else if (color[bbnew] == 1) { + BackEdges.insert(std::make_pair(bb, bbnew)); + //NumBackEdges++; + } + } + color[bb] = 2; + ++time; + finish[bb] = time; + } + + + + //find the back edges and where they go to + template + static void getBackEdges(Function& F, T& BackEdges) { + std::map color; + std::map depth; + std::map finish; + int time = 0; + recBackEdge(&F.getEntryBlock(), BackEdges, color, depth, finish, time); + DEBUG(std::cerr << F.getName() << " " << BackEdges.size() << "\n"); + } + + + //Creation functions + ModulePass* llvm::createBlockProfilerRSPass() { + return new BlockProfilerRS(); + } + + ModulePass* llvm::createFunctionProfilerRSPass() { + return new FunctionProfilerRS(); + } + + ModulePass* llvm::createNullProfilerRSPass() { + return new NullProfilerRS(); + } + + FunctionPass* llvm::createRSProfilingPass() { + return new ProfilerRS(); + } Index: llvm/lib/Transforms/Instrumentation/RSProfiling.h diff -c /dev/null llvm/lib/Transforms/Instrumentation/RSProfiling.h:1.1 *** /dev/null Sun Nov 27 18:58:21 2005 --- llvm/lib/Transforms/Instrumentation/RSProfiling.h Sun Nov 27 18:58:09 2005 *************** *** 0 **** --- 1,28 ---- + //===- RSProfiling.cpp - Various profiling using random sampling ----------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // See notes in RSProfiling.cpp + // + //===----------------------------------------------------------------------===// + + namespace llvm { + // By default, we provide some convienence stuff to clients, so they + // can just store the instructions they create to do profiling. + // also, handle all chaining issues. + // a client is free to overwrite these, as long as it implements the + // chaining itself. + struct RSProfilers : public ModulePass { + std::set profcode; + virtual bool isProfiling(Value* v); + virtual ~RSProfilers() {} + virtual void getAnalysisUsage(AnalysisUsage &AU) const; + void IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum, + GlobalValue *CounterArray); + }; + }; From lattner at cs.uiuc.edu Sun Nov 27 20:30:34 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 27 Nov 2005 20:30:34 -0600 Subject: [llvm-commits] CVS: llvm/docs/ProgrammersManual.html Message-ID: <200511280230.UAA14823@zion.cs.uiuc.edu> Changes in directory llvm/docs: ProgrammersManual.html updated: 1.88 -> 1.89 --- Log message: Use std:: where appropriate --- Diffs of the changes: (+5 -5) ProgrammersManual.html | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) Index: llvm/docs/ProgrammersManual.html diff -u llvm/docs/ProgrammersManual.html:1.88 llvm/docs/ProgrammersManual.html:1.89 --- llvm/docs/ProgrammersManual.html:1.88 Tue Nov 1 15:12:49 2005 +++ llvm/docs/ProgrammersManual.html Sun Nov 27 20:30:22 2005 @@ -590,7 +590,7 @@ an example that prints the name of a BasicBlock and the number of Instructions it contains:

-
  // func is a pointer to a Function instance
for (Function::iterator i = func->begin(), e = func->end(); i != e; ++i) {

// print out the name of the basic block if it has one, and then the
// number of instructions that it contains

cerr << "Basic block (name=" << i->getName() << ") has "
<< i->size() << " instructions.\n";
}
+
  // func is a pointer to a Function instance
for (Function::iterator i = func->begin(), e = func->end(); i != e; ++i) {

// print out the name of the basic block if it has one, and then the
// number of instructions that it contains

std::cerr << "Basic block (name=" << i->getName() << ") has "
<< i->size() << " instructions.\n";
}

Note that i can be used as if it were a pointer for the purposes of invoking member functions of the Instruction class. This is @@ -645,7 +645,7 @@ and then instantiate InstIterators explicitly in your code. Here's a small example that shows how to dump all instructions in a function to the standard error stream:

-

#include "llvm/Support/InstIterator.h"
...
// Suppose F is a ptr to a function
for (inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i)
cerr << *i << "\n";
+
#include "llvm/Support/InstIterator.h"
...
// Suppose F is a ptr to a function
for (inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i)
std::cerr << *i << "\n";
Easy, isn't it? You can also use InstIterators to fill a worklist with its initial contents. For example, if you wanted to initialize a worklist to contain all instructions in a Function @@ -693,7 +693,7 @@ iterators. By using these, you can explicitly grab the iterator of something without actually obtaining it via iteration over some structure:

-
void printNextInstruction(Instruction* inst) {
BasicBlock::iterator it(inst);
++it; // after this line, it refers to the instruction after *inst.
if (it != inst->getParent()->end()) cerr << *it << "\n";
}
+
void printNextInstruction(Instruction* inst) {
BasicBlock::iterator it(inst);
++it; // after this line, it refers to the instruction after *inst.
if (it != inst->getParent()->end()) std::cerr << *it << "\n";
}
@@ -768,7 +768,7 @@ use foo is as simple as iterating over the def-use chain of F:

-
Function* F = ...;

for (Value::use_iterator i = F->use_begin(), e = F->use_end(); i != e; ++i) {
if (Instruction *Inst = dyn_cast<Instruction>(*i)) {
cerr << "F is used in instruction:\n";
cerr << *Inst << "\n";
}
}
+
Function* F = ...;

for (Value::use_iterator i = F->use_begin(), e = F->use_end(); i != e; ++i) {
if (Instruction *Inst = dyn_cast<Instruction>(*i)) {
std::cerr << "F is used in instruction:\n";
std::cerr << *Inst << "\n";
}
}

Alternately, it's common to have an instance of the User Class and need to know what @@ -2277,7 +2277,7 @@ Dinakar Dhurjati and Chris Lattner
The LLVM Compiler Infrastructure
- Last modified: $Date: 2005/11/01 21:12:49 $ + Last modified: $Date: 2005/11/28 02:30:22 $ From lattner at cs.uiuc.edu Sun Nov 27 22:52:50 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 27 Nov 2005 22:52:50 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/README.txt Message-ID: <200511280452.WAA15385@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: README.txt updated: 1.16 -> 1.17 --- Log message: Add a missed optimization --- Diffs of the changes: (+9 -0) README.txt | 9 +++++++++ 1 files changed, 9 insertions(+) Index: llvm/lib/Target/X86/README.txt diff -u llvm/lib/Target/X86/README.txt:1.16 llvm/lib/Target/X86/README.txt:1.17 --- llvm/lib/Target/X86/README.txt:1.16 Sun Oct 23 16:45:00 2005 +++ llvm/lib/Target/X86/README.txt Sun Nov 27 22:52:39 2005 @@ -73,3 +73,12 @@ Should support emission of the bswap instruction, probably by adding a new DAG node for byte swapping. Also useful on PPC which has byte-swapping loads. +//===---------------------------------------------------------------------===// + +Compile this: +_Bool f(_Bool a) { return a!=1; } + +into: + movzbl %dil, %eax + xorl $1, %eax + ret