-C++ is a powerful language. With a firm grasp on its capabilities, you can make write effective, consise, readable and maintainable code all at the same time. By staying consistent, you reduce the amount of special cases that need to be remembered. Reducing the total number of lines of code you write is a good way to avoid documentation, and avoid giving bugs a place to hide.
-
-For these reasons, come to know and love the contents of your local <algorithm> header file. Know about <functional> and what it can do for you. C++ is just a tool that wants you to master it. :)
+C++ is a powerful language. With a firm grasp on its capabilities, you can make
+write effective, consise, readable and maintainable code all at the same time.
+By staying consistent, you reduce the amount of special cases that need to be
+remembered. Reducing the total number of lines of code you write is a good way
+to avoid documentation, and avoid giving bugs a place to hide.
+
+For these reasons, come to know and love the contents of your local
+<algorithm> header file. Know about <functional> and what it can do
+for you. C++ is just a tool that wants you to master it. :)
From lattner at cs.uiuc.edu Tue Jul 29 00:14:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Jul 29 00:14:01 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/Target/MRegisterInfo.h
Message-ID: <200307290513.AAA31079@apoc.cs.uiuc.edu>
Changes in directory llvm/include/llvm/Target:
MRegisterInfo.h updated: 1.18 -> 1.19
---
Log message:
Move value type enums to CodeGen/ValueTypes.h
---
Diffs of the changes:
Index: llvm/include/llvm/Target/MRegisterInfo.h
diff -u llvm/include/llvm/Target/MRegisterInfo.h:1.18 llvm/include/llvm/Target/MRegisterInfo.h:1.19
--- llvm/include/llvm/Target/MRegisterInfo.h:1.18 Fri Jul 25 12:58:41 2003
+++ llvm/include/llvm/Target/MRegisterInfo.h Tue Jul 29 00:13:34 2003
@@ -1,4 +1,4 @@
-//===- Target/MRegisterInfo.h - Target Register Information -------*-C++-*-===//
+//===- Target/MRegisterInfo.h - Target Register Information -----*- C++ -*-===//
//
// This file describes an abstract interface used to get information about a
// target machines register file. This information is used for a variety of
@@ -26,25 +26,6 @@
const unsigned *AliasSet; // Register Alias Set, described above
unsigned Flags; // Flags identifying register properties (below)
unsigned TSFlags; // Target Specific Flags
-};
-
-/// MRF namespace - This namespace contains flags that pertain to machine
-/// registers
-///
-namespace MRF { // MRF = Machine Register Flags
- enum {
- Other = 0 << 0, // This is a non-standard register
- INT8 = 1 << 0, // This is an 8 bit integer register
- INT16 = 1 << 1, // This is a 16 bit integer register
- INT32 = 1 << 2, // This is a 32 bit integer register
- INT64 = 1 << 3, // This is a 64 bit integer register
- INT128 = 1 << 4, // This is a 128 bit integer register
-
- FP32 = 1 << 5, // This is a 32 bit floating point register
- FP64 = 1 << 6, // This is a 64 bit floating point register
- FP80 = 1 << 7, // This is a 80 bit floating point register
- FP128 = 1 << 8, // This is a 128 bit floating point register
- };
};
class TargetRegisterClass {
From lattner at cs.uiuc.edu Tue Jul 29 00:14:04 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Jul 29 00:14:04 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/ValueTypes.h
Message-ID: <200307290513.AAA30819@apoc.cs.uiuc.edu>
Changes in directory llvm/include/llvm/CodeGen:
ValueTypes.h added (r1.1)
---
Log message:
Define target value types in a form usable by target-independent code
---
Diffs of the changes:
Index: llvm/include/llvm/CodeGen/ValueTypes.h
diff -c /dev/null llvm/include/llvm/CodeGen/ValueTypes.h:1.1
*** /dev/null Tue Jul 29 00:13:21 2003
--- llvm/include/llvm/CodeGen/ValueTypes.h Tue Jul 29 00:13:09 2003
***************
*** 0 ****
--- 1,33 ----
+ //===- CodeGen/ValueTypes.h - Low-Level Target independ. types --*- C++ -*-===//
+ //
+ // This file defines the set of low-level target independent types which various
+ // values in the code generator are. This allows the target specific behavior
+ // of instructions to be described to target independent passes.
+ //
+ //===----------------------------------------------------------------------===//
+
+ #ifndef LLVM_CODEGEN_VALUETYPES_H
+ #define LLVM_CODEGEN_VALUETYPES_H
+
+ /// MVT namespace - This namespace defines the ValueType enum, which contains
+ /// the various low-level value types.
+ ///
+ namespace MVT { // MRF = Machine Register Flags
+ enum ValueType {
+ Other = 0 << 0, // This is a non-standard value
+ i1 = 1 << 0, // This is a 1 bit integer value
+ i8 = 1 << 1, // This is an 8 bit integer value
+ i16 = 1 << 2, // This is a 16 bit integer value
+ i32 = 1 << 3, // This is a 32 bit integer value
+ i64 = 1 << 4, // This is a 64 bit integer value
+ i128 = 1 << 5, // This is a 128 bit integer value
+
+ f32 = 1 << 6, // This is a 32 bit floating point value
+ f64 = 1 << 7, // This is a 64 bit floating point value
+ f80 = 1 << 8, // This is a 80 bit floating point value
+ f128 = 1 << 9, // This is a 128 bit floating point value
+ };
+ };
+
+ #endif
+
From lattner at cs.uiuc.edu Tue Jul 29 00:15:02 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Jul 29 00:15:02 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.cpp X86RegisterInfo.def
Message-ID: <200307290514.AAA31096@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Target/X86:
X86RegisterInfo.cpp updated: 1.31 -> 1.32
X86RegisterInfo.def updated: 1.13 -> 1.14
---
Log message:
Move "register flags" definition the type of registers to be fully fledged
value types
---
Diffs of the changes:
Index: llvm/lib/Target/X86/X86RegisterInfo.cpp
diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.31 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.32
--- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.31 Wed Feb 26 13:58:15 2003
+++ llvm/lib/Target/X86/X86RegisterInfo.cpp Tue Jul 29 00:14:16 2003
@@ -10,6 +10,7 @@
#include "X86InstrBuilder.h"
#include "llvm/Constants.h"
#include "llvm/Type.h"
+#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
Index: llvm/lib/Target/X86/X86RegisterInfo.def
diff -u llvm/lib/Target/X86/X86RegisterInfo.def:1.13 llvm/lib/Target/X86/X86RegisterInfo.def:1.14
--- llvm/lib/Target/X86/X86RegisterInfo.def:1.13 Tue Apr 22 15:20:11 2003
+++ llvm/lib/Target/X86/X86RegisterInfo.def Tue Jul 29 00:14:16 2003
@@ -61,60 +61,60 @@
R(NoReg,"none", 0, 0, 0/*noalias*/)
// 32 bit registers, ordered as the processor does...
-R32(EAX, "EAX", MRF::INT32, 0, A_EAX)
-R32(ECX, "ECX", MRF::INT32, 0, A_ECX)
-R32(EDX, "EDX", MRF::INT32, 0, A_EDX)
-R32(EBX, "EBX", MRF::INT32, 0, A_EBX)
-R32(ESP, "ESP", MRF::INT32, 0, A_ESP)
-R32(EBP, "EBP", MRF::INT32, 0, A_EBP)
-R32(ESI, "ESI", MRF::INT32, 0, A_ESI)
-R32(EDI, "EDI", MRF::INT32, 0, A_EDI)
+R32(EAX, "EAX", MVT::i32, 0, A_EAX)
+R32(ECX, "ECX", MVT::i32, 0, A_ECX)
+R32(EDX, "EDX", MVT::i32, 0, A_EDX)
+R32(EBX, "EBX", MVT::i32, 0, A_EBX)
+R32(ESP, "ESP", MVT::i32, 0, A_ESP)
+R32(EBP, "EBP", MVT::i32, 0, A_EBP)
+R32(ESI, "ESI", MVT::i32, 0, A_ESI)
+R32(EDI, "EDI", MVT::i32, 0, A_EDI)
// 16 bit registers, aliased with the corresponding 32 bit registers above
-R16( AX, "AX" , MRF::INT16, 0, A_AX)
-R16( CX, "CX" , MRF::INT16, 0, A_CX)
-R16( DX, "DX" , MRF::INT16, 0, A_DX)
-R16( BX, "BX" , MRF::INT16, 0, A_BX)
-R16( SP, "SP" , MRF::INT16, 0, A_SP)
-R16( BP, "BP" , MRF::INT16, 0, A_BP)
-R16( SI, "SI" , MRF::INT16, 0, A_SI)
-R16( DI, "DI" , MRF::INT16, 0, A_DI)
+R16( AX, "AX" , MVT::i16, 0, A_AX)
+R16( CX, "CX" , MVT::i16, 0, A_CX)
+R16( DX, "DX" , MVT::i16, 0, A_DX)
+R16( BX, "BX" , MVT::i16, 0, A_BX)
+R16( SP, "SP" , MVT::i16, 0, A_SP)
+R16( BP, "BP" , MVT::i16, 0, A_BP)
+R16( SI, "SI" , MVT::i16, 0, A_SI)
+R16( DI, "DI" , MVT::i16, 0, A_DI)
// 8 bit registers aliased with registers above as well
-R8 ( AL, "AL" , MRF::INT8 , 0, A_AL)
-R8 ( CL, "CL" , MRF::INT8 , 0, A_CL)
-R8 ( DL, "DL" , MRF::INT8 , 0, A_DL)
-R8 ( BL, "BL" , MRF::INT8 , 0, A_BL)
-R8 ( AH, "AH" , MRF::INT8 , 0, A_AH)
-R8 ( CH, "CH" , MRF::INT8 , 0, A_CH)
-R8 ( DH, "DH" , MRF::INT8 , 0, A_DH)
-R8 ( BH, "BH" , MRF::INT8 , 0, A_BH)
+R8 ( AL, "AL" , MVT::i8 , 0, A_AL)
+R8 ( CL, "CL" , MVT::i8 , 0, A_CL)
+R8 ( DL, "DL" , MVT::i8 , 0, A_DL)
+R8 ( BL, "BL" , MVT::i8 , 0, A_BL)
+R8 ( AH, "AH" , MVT::i8 , 0, A_AH)
+R8 ( CH, "CH" , MVT::i8 , 0, A_CH)
+R8 ( DH, "DH" , MVT::i8 , 0, A_DH)
+R8 ( BH, "BH" , MVT::i8 , 0, A_BH)
// Pseudo Floating Point Registers
-PFP(FP0, "FP0", MRF::FP80 , 0, 0 /*noalias*/)
-PFP(FP1, "FP1", MRF::FP80 , 0, 0 /*noalias*/)
-PFP(FP2, "FP2", MRF::FP80 , 0, 0 /*noalias*/)
-PFP(FP3, "FP3", MRF::FP80 , 0, 0 /*noalias*/)
-PFP(FP4, "FP4", MRF::FP80 , 0, 0 /*noalias*/)
-PFP(FP5, "FP5", MRF::FP80 , 0, 0 /*noalias*/)
-PFP(FP6, "FP6", MRF::FP80 , 0, 0 /*noalias*/)
+PFP(FP0, "FP0", MVT::f80 , 0, 0 /*noalias*/)
+PFP(FP1, "FP1", MVT::f80 , 0, 0 /*noalias*/)
+PFP(FP2, "FP2", MVT::f80 , 0, 0 /*noalias*/)
+PFP(FP3, "FP3", MVT::f80 , 0, 0 /*noalias*/)
+PFP(FP4, "FP4", MVT::f80 , 0, 0 /*noalias*/)
+PFP(FP5, "FP5", MVT::f80 , 0, 0 /*noalias*/)
+PFP(FP6, "FP6", MVT::f80 , 0, 0 /*noalias*/)
// Floating point stack registers
-FPS(ST0, "ST(0)", MRF::FP80, 0, 0)
-FPS(ST1, "ST(1)", MRF::FP80, 0, 0)
-FPS(ST2, "ST(2)", MRF::FP80, 0, 0)
-FPS(ST3, "ST(3)", MRF::FP80, 0, 0)
-FPS(ST4, "ST(4)", MRF::FP80, 0, 0)
-FPS(ST5, "ST(5)", MRF::FP80, 0, 0)
-FPS(ST6, "ST(6)", MRF::FP80, 0, 0)
-FPS(ST7, "ST(7)", MRF::FP80, 0, 0)
+FPS(ST0, "ST(0)", MVT::f80, 0, 0)
+FPS(ST1, "ST(1)", MVT::f80, 0, 0)
+FPS(ST2, "ST(2)", MVT::f80, 0, 0)
+FPS(ST3, "ST(3)", MVT::f80, 0, 0)
+FPS(ST4, "ST(4)", MVT::f80, 0, 0)
+FPS(ST5, "ST(5)", MVT::f80, 0, 0)
+FPS(ST6, "ST(6)", MVT::f80, 0, 0)
+FPS(ST7, "ST(7)", MVT::f80, 0, 0)
// Flags, Segment registers, etc...
// This is a slimy hack to make it possible to say that flags are clobbered...
// Ideally we'd model instructions based on which particular flag(s) they
// could clobber.
-R(EFLAGS, "EFLAGS", MRF::INT16, 0, 0 /*noalias*/)
+R(EFLAGS, "EFLAGS", MVT::i16, 0, 0 /*noalias*/)
//===----------------------------------------------------------------------===//
From lattner at cs.uiuc.edu Tue Jul 29 00:16:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Jul 29 00:16:01 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/ValueTypes.h
Message-ID: <200307290515.AAA31557@apoc.cs.uiuc.edu>
Changes in directory llvm/include/llvm/CodeGen:
ValueTypes.h updated: 1.1 -> 1.2
---
Log message:
Fix copy and paste-o
---
Diffs of the changes:
Index: llvm/include/llvm/CodeGen/ValueTypes.h
diff -u llvm/include/llvm/CodeGen/ValueTypes.h:1.1 llvm/include/llvm/CodeGen/ValueTypes.h:1.2
--- llvm/include/llvm/CodeGen/ValueTypes.h:1.1 Tue Jul 29 00:13:09 2003
+++ llvm/include/llvm/CodeGen/ValueTypes.h Tue Jul 29 00:15:44 2003
@@ -12,7 +12,7 @@
/// MVT namespace - This namespace defines the ValueType enum, which contains
/// the various low-level value types.
///
-namespace MVT { // MRF = Machine Register Flags
+namespace MVT { // MVT = Machine Value Types
enum ValueType {
Other = 0 << 0, // This is a non-standard value
i1 = 1 << 0, // This is a 1 bit integer value
From vadve at cs.uiuc.edu Tue Jul 29 09:03:01 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 09:03:01 2003
Subject: [llvm-commits] CVS: llvm/test/Regression/LLC/2003-07-29-BadConstSbyte.ll
Message-ID: <200307291402.JAA32513@psmith.cs.uiuc.edu>
Changes in directory llvm/test/Regression/LLC:
2003-07-29-BadConstSbyte.ll added (r1.1)
---
Log message:
Regression test for incorrect character emitted to char array.
---
Diffs of the changes:
Index: llvm/test/Regression/LLC/2003-07-29-BadConstSbyte.ll
diff -c /dev/null llvm/test/Regression/LLC/2003-07-29-BadConstSbyte.ll:1.1
*** /dev/null Tue Jul 29 09:02:50 2003
--- llvm/test/Regression/LLC/2003-07-29-BadConstSbyte.ll Tue Jul 29 09:02:40 2003
***************
*** 0 ****
--- 1,39 ----
+ ;; Date: Jul 29, 2003.
+ ;; From: test/Programs/MultiSource/Ptrdist-bc
+ ;; Function: ---
+ ;; Global: %yy_ec = internal constant [256 x sbyte] ...
+ ;; A subset of this array is used in the test below.
+ ;;
+ ;; Error: Character '\07' was being emitted as '\a', at yy_ec[38].
+ ;; When loaded, this returned the value 97 ('a'), instead of 7.
+ ;;
+ ;; Incorrect LLC Output for the array yy_ec was:
+ ;; yy_ec_1094:
+ ;; .ascii "\000\001\001\001\001\001\001\001\001\002\003\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\002\004\005\001\001\006\a\001\b\t\n\v\f\r\016\017\020\020\020\020\020\020\020\020\020\020\001\021\022\023\024\001\001\025\025\025\025\025\025\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\026\027\030\031\032\001\033\034\035\036\037 !\"#$%&'()*+,-./$0$1$234\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001"
+ ;;
+
+
+ %yy_ec = internal constant [6 x sbyte] c"\06\07\01\08\01\09"
+
+ %.str_3 = internal constant [8 x sbyte] c"[%d] = \00"
+ %.str_4 = internal constant [4 x sbyte] c"%d\0A\00"
+
+ implementation
+
+ declare int %printf(sbyte*, ...)
+
+ int %main() {
+ entry:
+ br label %loopentry
+ loopentry:
+ %i = phi long [0, %entry], [%inc.i, %loopentry]
+ %cptr = getelementptr [6 x sbyte]* %yy_ec, long 0, long %i
+ %c = load sbyte* %cptr
+ %ignore = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([8 x sbyte]* %.str_3, long 0, long 0), long %i)
+ %ignore2 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([4 x sbyte]* %.str_4, long 0, long 0), sbyte %c)
+ %inc.i = add long %i, 1
+ %done = setle long %inc.i, 5
+ br bool %done, label %loopentry, label %exit.1
+ exit.1:
+ ret int 0
+ };
From brukman at cs.uiuc.edu Tue Jul 29 11:03:02 2003
From: brukman at cs.uiuc.edu (Misha Brukman)
Date: Tue Jul 29 11:03:02 2003
Subject: [llvm-commits] CVS: llvm/tools/bugpoint/CodeGeneratorBug.cpp
Message-ID: <200307291602.LAA11779@zion.cs.uiuc.edu>
Changes in directory llvm/tools/bugpoint:
CodeGeneratorBug.cpp updated: 1.4 -> 1.5
---
Log message:
* Disambiguate symbols before we start splitting module by functions
* Moved DisambiguateGlobalSymbols() out of the ReduceMisCodegenFunctions class
* Added an assert to have a cleaner exit if `main' is not found in the module
---
Diffs of the changes:
Index: llvm/tools/bugpoint/CodeGeneratorBug.cpp
diff -u llvm/tools/bugpoint/CodeGeneratorBug.cpp:1.4 llvm/tools/bugpoint/CodeGeneratorBug.cpp:1.5
--- llvm/tools/bugpoint/CodeGeneratorBug.cpp:1.4 Mon Jul 28 16:07:39 2003
+++ llvm/tools/bugpoint/CodeGeneratorBug.cpp Tue Jul 29 11:02:28 2003
@@ -41,8 +41,6 @@
bool TestFuncs(const std::vector &CodegenTest,
bool KeepFiles = false);
-
- void DisambiguateGlobalSymbols(Module *M);
};
@@ -64,7 +62,6 @@
for (Module::giterator I=SafeModule->gbegin(),E = SafeModule->gend();I!=E;++I)
I->setLinkage(GlobalValue::ExternalLinkage);
- DisambiguateGlobalSymbols(SafeModule);
Module *TestModule = CloneModule(SafeModule);
// Make sure global initializers exist only in the safe module (CBE->.so)
@@ -75,6 +72,7 @@
for (unsigned i = 0, e = Funcs.size(); i != e; ++i) {
Function *TNOF = SafeModule->getFunction(Funcs[i]->getName(),
Funcs[i]->getFunctionType());
+ DEBUG(std::cerr << "Removing function " << Funcs[i]->getName() << "\n");
assert(TNOF && "Function doesn't exist in module!");
DeleteFunctionBody(TNOF); // Function is now external in this module!
}
@@ -96,6 +94,7 @@
if (BD.isExecutingJIT()) {
// Must delete `main' from Safe module if it has it
Function *safeMain = SafeModule->getNamedFunction("main");
+ assert(safeMain && "`main' function not found in safe module!");
DeleteFunctionBody(safeMain);
// Add an external function "getPointerToNamedFunction" that JIT provides
@@ -283,7 +282,7 @@
};
}
-void ReduceMisCodegenFunctions::DisambiguateGlobalSymbols(Module *M) {
+void DisambiguateGlobalSymbols(Module *M) {
// First, try not to cause collisions by minimizing chances of renaming an
// already-external symbol, so take in external globals and functions as-is.
Disambiguator D;
@@ -317,6 +316,7 @@
if (isExecutingJIT()) {
// Get the `main' function
Function *oldMain = Program->getNamedFunction("main");
+ assert(oldMain && "`main' function not found in program!");
// Rename it
oldMain->setName("old_main");
// Create a NEW `main' function with same type
@@ -343,6 +343,8 @@
BB->getInstList().push_back(ret);
}
+ DisambiguateGlobalSymbols(Program);
+
// Do the reduction...
ReduceMisCodegenFunctions(*this).reduceList(MisCodegenFunctions);
@@ -355,4 +357,3 @@
return false;
}
-
From brukman at cs.uiuc.edu Tue Jul 29 11:58:01 2003
From: brukman at cs.uiuc.edu (Misha Brukman)
Date: Tue Jul 29 11:58:01 2003
Subject: [llvm-commits] CVS: llvm/tools/lli/JIT/Emitter.cpp
Message-ID: <200307291657.LAA22066@zion.cs.uiuc.edu>
Changes in directory llvm/tools/lli/JIT:
Emitter.cpp updated: 1.19 -> 1.20
---
Log message:
* Stop hard-coding a value for beginning of emitted code on Sparc since we can
now handle far calls (i.e., beyond the 30-bit limit in call instructions).
* As a side-effect, this allows us to unify and clean up the mmap() call and
code around it.
---
Diffs of the changes:
Index: llvm/tools/lli/JIT/Emitter.cpp
diff -u llvm/tools/lli/JIT/Emitter.cpp:1.19 llvm/tools/lli/JIT/Emitter.cpp:1.20
--- llvm/tools/lli/JIT/Emitter.cpp:1.19 Mon Jul 28 14:26:19 2003
+++ llvm/tools/lli/JIT/Emitter.cpp Tue Jul 29 11:57:16 2003
@@ -76,20 +76,16 @@
/* Linux and *BSD tend to have these flags named differently. */
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
# define MAP_ANONYMOUS MAP_ANON
-#endif
- pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
- MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); /* fd = 0 */
+#endif /* defined(MAP_ANON) && !defined(MAP_ANONYMOUS) */
+#define fd 0
#elif defined(sparc) || defined(__sparc__) || defined(__sparcv9)
- static unsigned long Counter = 0;
- pa = mmap((void*)(0x140000000UL+Counter), pageSize*NumPages,
- PROT_READ|PROT_WRITE|PROT_EXEC,
- MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0); /* fd = -1 */
- Counter += pageSize*NumPages;
+#define fd -1
#else
- std::cerr << "This architecture is not supported by the JIT\n";
+ std::cerr << "This architecture is not supported by the JIT!\n";
abort();
#endif
-
+ pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
+ MAP_PRIVATE|MAP_ANONYMOUS, fd, 0);
if (pa == MAP_FAILED) {
perror("mmap");
abort();
From brukman at cs.uiuc.edu Tue Jul 29 14:02:02 2003
From: brukman at cs.uiuc.edu (Misha Brukman)
Date: Tue Jul 29 14:02:02 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp
Message-ID: <200307291901.OAA01353@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/Sparc:
SparcV9CodeEmitter.cpp updated: 1.22 -> 1.23
---
Log message:
* Correctly emit a far call if the target address does not fit into 30 bits
instead of assert()ing
* Fixed a nasty bug where '07' was used instead of register 'o7'
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp
diff -u llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.22 llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.23
--- llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.22 Sat Jul 26 18:04:00 2003
+++ llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp Tue Jul 29 14:00:58 2003
@@ -286,22 +286,20 @@
int64_t CurrPC = MCE.getCurrentPCValue();
int64_t Addr = (int64_t)addFunctionReference(CurrPC, F);
-
int64_t CallTarget = (Addr-CurrPC) >> 2;
if (CallTarget >= (1 << 30) || CallTarget <= -(1 << 30)) {
- std::cerr << "Call target beyond 30 bit limit of CALL: "
- << CallTarget << "\n";
- abort();
- }
- // call CallTarget ;; invoke the callback
- MachineInstr *Call = BuildMI(V9::CALL, 1).addSImm(CallTarget);
- SparcV9.emitWord(SparcV9.getBinaryCodeForInstr(*Call));
- delete Call;
+ SparcV9.emitFarCall(Addr);
+ } else {
+ // call CallTarget ;; invoke the callback
+ MachineInstr *Call = BuildMI(V9::CALL, 1).addSImm(CallTarget);
+ SparcV9.emitWord(SparcV9.getBinaryCodeForInstr(*Call));
+ delete Call;
- // nop ;; call delay slot
- MachineInstr *Nop = BuildMI(V9::NOP, 0);
- SparcV9.emitWord(SparcV9.getBinaryCodeForInstr(*Nop));
- delete Nop;
+ // nop ;; call delay slot
+ MachineInstr *Nop = BuildMI(V9::NOP, 0);
+ SparcV9.emitWord(SparcV9.getBinaryCodeForInstr(*Nop));
+ delete Nop;
+ }
SparcV9.emitWord(0xDEADBEEF); // marker so that we know it's really a stub
return (intptr_t)MCE.finishFunctionStub(*F);
@@ -394,8 +392,8 @@
// being accounted for, and the behavior will be incorrect!!
inline void SparcV9CodeEmitter::emitFarCall(uint64_t Target) {
static const unsigned i1 = SparcIntRegClass::i1, i2 = SparcIntRegClass::i2,
- i7 = SparcIntRegClass::i7,
- o6 = SparcIntRegClass::o6, g0 = SparcIntRegClass::g0;
+ i7 = SparcIntRegClass::i7, o6 = SparcIntRegClass::o6,
+ o7 = SparcIntRegClass::o7, g0 = SparcIntRegClass::g0;
//
// Save %i1, %i2 to the stack so we can form a 64-bit constant in %i2
@@ -451,8 +449,8 @@
emitWord(getBinaryCodeForInstr(*LDX));
delete LDX;
- // jmpl %i2, %g0, %07 ;; indirect call on %i2
- MachineInstr *J = BuildMI(V9::JMPLRETr, 3).addReg(i2).addReg(g0).addReg(07);
+ // jmpl %i2, %g0, %o7 ;; indirect call on %i2
+ MachineInstr *J = BuildMI(V9::JMPLRETr, 3).addReg(i2).addReg(g0).addReg(o7);
emitWord(getBinaryCodeForInstr(*J));
delete J;
From criswell at cs.uiuc.edu Tue Jul 29 14:12:02 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Tue Jul 29 14:12:02 2003
Subject: [llvm-commits] CVS: llvm/autoconf/aclocal.m4 configure.ac
Message-ID: <200307291912.OAA16962@choi.cs.uiuc.edu>
Changes in directory llvm/autoconf:
aclocal.m4 updated: 1.2 -> 1.3
configure.ac updated: 1.2 -> 1.3
---
Log message:
Enable JIT when the platform supports it.
Select /localhome/$USER when it exists.
Fix the checks for bidirectional and forward iterators so that they work with
version of GCC prior to 3.x.
---
Diffs of the changes:
Index: llvm/autoconf/aclocal.m4
diff -u llvm/autoconf/aclocal.m4:1.2 llvm/autoconf/aclocal.m4:1.3
--- llvm/autoconf/aclocal.m4:1.2 Wed Jul 23 11:52:50 2003
+++ llvm/autoconf/aclocal.m4 Tue Jul 29 14:11:50 2003
@@ -5983,7 +5983,7 @@
AC_TRY_COMPILE([#include
#ifdef HAVE_NAMESPACES
using namespace std;
-#endif],[bidirectional_iterator t; return 0;],
+#endif],[bidirectional_iterator t; return 0;],
ac_cv_cxx_have_bi_iterator=yes, ac_cv_cxx_have_bi_iterator=no)
AC_LANG_RESTORE
])
@@ -5993,7 +5993,7 @@
])
#
-# Check for standard iterator extension. This is modified from
+# Check for forward iterator extension. This is modified from
# http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_hash_set.html
#
AC_DEFUN([AC_CXX_HAVE_FWD_ITERATOR],
@@ -6005,7 +6005,7 @@
AC_TRY_COMPILE([#include
#ifdef HAVE_NAMESPACES
using namespace std;
-#endif],[forward_iterator t; return 0;],
+#endif],[forward_iterator t; return 0;],
ac_cv_cxx_have_fwd_iterator=yes, ac_cv_cxx_have_fwd_iterator=no)
AC_LANG_RESTORE
])
Index: llvm/autoconf/configure.ac
diff -u llvm/autoconf/configure.ac:1.2 llvm/autoconf/configure.ac:1.3
--- llvm/autoconf/configure.ac:1.2 Tue Jul 22 15:59:52 2003
+++ llvm/autoconf/configure.ac Tue Jul 29 14:11:50 2003
@@ -272,23 +272,55 @@
fi
dnl JIT Option
-AC_ARG_ENABLE(jit,AC_HELP_STRING([--enable-jit],[Enable Just In Time Compiling (default is NO)]),,enableval=no)
+AC_ARG_ENABLE(jit,AC_HELP_STRING([--enable-jit],[Enable Just In Time Compiling (default is YES)]),,enableval=default)
if test ${enableval} = "no"
then
AC_SUBST(JIT,[[]])
else
- AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
+ case $target in
+ *i*86*)
+ AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
+ ;;
+ *sparc*)
+ AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
+ ;;
+ *)
+ AC_SUBST(JIT,[[]])
+ ;;
+ esac
fi
dnl **************************************************************************
dnl * Set the location of various third-party software packages
dnl **************************************************************************
+
+dnl Location of SPEC benchmarks
AC_ARG_WITH(spec,AC_HELP_STRING([--with-spec],[Location of SPEC benchmarks]),AC_SUBST(SPEC_ROOT,[$withval]),AC_SUBST(SPEC_ROOT,[/home/vadve/shared/benchmarks/speccpu2000/benchspec]))
+
+dnl Location of the LLVM C front end
AC_ARG_WITH(llvmgccdir,AC_HELP_STRING([--with-llvmgccdir],[Location of LLVM GCC front-end]),AC_SUBST(LLVMGCCDIR,[$withval]))
+
+dnl Location of the bytecode repository
AC_ARG_WITH(bcrepos,AC_HELP_STRING([--with-bcrepos],[Location of Bytecode Repository]),AC_SUBST(BCR,[$withval]),AC_SUBST(BCR,[/home/vadve/lattner/LLVMPrograms]))
+
+dnl Location of PAPI
AC_ARG_WITH(papi,AC_HELP_STRING([--with-papi],[Location of PAPI]),AC_SUBST(PAPIDIR,[$withval]),AC_SUBST(PAPIDIR,[/home/vadve/shared/papi-2.3.4.1]))
-AC_ARG_WITH(objroot,AC_HELP_STRING([--with-objroot],[Location where object files should be placed (default is .)]),AC_SUBST(OBJROOT,[$withval]),AC_SUBST(OBJROOT,[.]))
+
+dnl Location of the purify program
AC_ARG_WITH(purify,AC_HELP_STRING([--with-purify],[Location of purify program]),AC_SUBST(PURIFY,[$withval]))
+dnl Location for placing object files and built programs, libraries, etc
+if test -d /localhome
+then
+ AC_SUBST(OBJROOT,[/localhome/$USER])
+else
+ AC_SUBST(OBJROOT,[.])
+fi
+
+AC_ARG_WITH(objroot,AC_HELP_STRING([--with-objroot],[Location where object files should be placed (default is .)]),AC_SUBST(OBJROOT,[$withval]))
+
+dnl **************************************************************************
+dnl * Create the output files
+dnl **************************************************************************
AC_OUTPUT(Makefile.config)
From criswell at cs.uiuc.edu Tue Jul 29 14:13:02 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Tue Jul 29 14:13:02 2003
Subject: [llvm-commits] CVS: llvm/configure
Message-ID: <200307291912.OAA17190@choi.cs.uiuc.edu>
Changes in directory llvm:
configure updated: 1.10 -> 1.11
---
Log message:
Enable JIT when the platform supports it.
Select /localhome/$USER when it exists.
Fix the checks for bidirectional and forward iterators so that they work with
version of GCC prior to 3.x.
---
Diffs of the changes:
Index: llvm/configure
diff -u llvm/configure:1.10 llvm/configure:1.11
--- llvm/configure:1.10 Wed Jul 23 11:52:46 2003
+++ llvm/configure Tue Jul 29 14:11:46 2003
@@ -1035,7 +1035,7 @@
--enable-precompiled_bytecode
Use pre-compiled bytecode (default is NO)
--enable-llc_diffs Enable LLC Diffs when testing (default is YES)
- --enable-jit Enable Just In Time Compiling (default is NO)
+ --enable-jit Enable Just In Time Compiling (default is YES)
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -1049,9 +1049,9 @@
--with-llvmgccdir Location of LLVM GCC front-end
--with-bcrepos Location of Bytecode Repository
--with-papi Location of PAPI
+ --with-purify Location of purify program
--with-objroot Location where object files should be placed
(default is .)
- --with-purify Location of purify program
Some influential environment variables:
CXX C++ compiler command
@@ -20476,7 +20476,7 @@
int
main ()
{
-bidirectional_iterator t; return 0;
+bidirectional_iterator t; return 0;
;
return 0;
}
@@ -20547,7 +20547,7 @@
int
main ()
{
-forward_iterator t; return 0;
+forward_iterator t; return 0;
;
return 0;
}
@@ -22005,7 +22005,7 @@
enableval="$enable_jit"
else
- enableval=no
+ enableval=default
fi;
if test ${enableval} = "no"
@@ -22013,11 +22013,24 @@
JIT=
else
- JIT=TARGET_HAS_JIT=1
+ case $target in
+ *i*86*)
+ JIT=TARGET_HAS_JIT=1
+
+ ;;
+ *sparc*)
+ JIT=TARGET_HAS_JIT=1
+
+ ;;
+ *)
+ JIT=
+ ;;
+ esac
fi
+
# Check whether --with-spec or --without-spec was given.
if test "${with_spec+set}" = set; then
withval="$with_spec"
@@ -22028,6 +22041,7 @@
fi;
+
# Check whether --with-llvmgccdir or --without-llvmgccdir was given.
if test "${with_llvmgccdir+set}" = set; then
withval="$with_llvmgccdir"
@@ -22035,6 +22049,7 @@
fi;
+
# Check whether --with-bcrepos or --without-bcrepos was given.
if test "${with_bcrepos+set}" = set; then
withval="$with_bcrepos"
@@ -22045,6 +22060,7 @@
fi;
+
# Check whether --with-papi or --without-papi was given.
if test "${with_papi+set}" = set; then
withval="$with_papi"
@@ -22055,20 +22071,28 @@
fi;
-# Check whether --with-objroot or --without-objroot was given.
-if test "${with_objroot+set}" = set; then
- withval="$with_objroot"
- OBJROOT=$withval
-
-else
- OBJROOT=.
-
-fi;
# Check whether --with-purify or --without-purify was given.
if test "${with_purify+set}" = set; then
withval="$with_purify"
PURIFY=$withval
+
+fi;
+
+if test -d /localhome
+then
+ OBJROOT=/localhome/$USER
+
+else
+ OBJROOT=.
+
+fi
+
+
+# Check whether --with-objroot or --without-objroot was given.
+if test "${with_objroot+set}" = set; then
+ withval="$with_objroot"
+ OBJROOT=$withval
fi;
From criswell at cs.uiuc.edu Tue Jul 29 14:13:05 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Tue Jul 29 14:13:05 2003
Subject: [llvm-commits] CVS: llvm/include/Support/iterator
Message-ID: <200307291912.OAA16978@choi.cs.uiuc.edu>
Changes in directory llvm/include/Support:
iterator updated: 1.4 -> 1.5
---
Log message:
Enable JIT when the platform supports it.
Select /localhome/$USER when it exists.
Fix the checks for bidirectional and forward iterators so that they work with
version of GCC prior to 3.x.
---
Diffs of the changes:
Index: llvm/include/Support/iterator
diff -u llvm/include/Support/iterator:1.4 llvm/include/Support/iterator:1.5
--- llvm/include/Support/iterator:1.4 Mon Jun 30 16:58:24 2003
+++ llvm/include/Support/iterator Tue Jul 29 14:11:58 2003
@@ -23,6 +23,11 @@
#include
+//////////////////////////////////////////////////////////////////////////////
+// If the bidirectional iterator is not defined, attempt to define it using
+// the C++ standard iterator.
+//////////////////////////////////////////////////////////////////////////////
+#ifndef HAVE_BI_ITERATOR
#ifdef HAVE_STD_ITERATOR
// Define stupid wrappers around std::iterator...
@@ -31,16 +36,34 @@
: public std::iterator {
};
-template
-struct forward_iterator
- : public std::iterator {
-};
+#else
+#error "Need to have standard iterator to define bidirectional iterator!"
+#endif
#else
// Just use bidirectional_iterator directly.
using std::bidirectional_iterator;
+
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+// If the forward iterator is not defined, attempt to define it using the
+// C++ standard iterator.
+//////////////////////////////////////////////////////////////////////////////
+#ifndef HAVE_FWD_ITERATOR
+#ifdef HAVE_STD_ITERATOR
+template
+struct forward_iterator
+ : public std::iterator {
+};
+#else
+#error "Need to have standard iterator to define forward iterator!"
+#endif
+#else
+// Just use forward iterator directly.
using std::forward_iterator;
#endif
+
#endif
From criswell at cs.uiuc.edu Tue Jul 29 14:13:07 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Tue Jul 29 14:13:07 2003
Subject: [llvm-commits] CVS: llvm/include/Config/config.h.in
Message-ID: <200307291912.OAA16969@choi.cs.uiuc.edu>
Changes in directory llvm/include/Config:
config.h.in updated: 1.2 -> 1.3
---
Log message:
Enable JIT when the platform supports it.
Select /localhome/$USER when it exists.
Fix the checks for bidirectional and forward iterators so that they work with
version of GCC prior to 3.x.
---
Diffs of the changes:
Index: llvm/include/Config/config.h.in
diff -u llvm/include/Config/config.h.in:1.2 llvm/include/Config/config.h.in:1.3
--- llvm/include/Config/config.h.in:1.2 Mon Jun 30 16:58:17 2003
+++ llvm/include/Config/config.h.in Tue Jul 29 14:11:54 2003
@@ -185,6 +185,8 @@
/* Indicates whether we have STL iterators */
#undef HAVE_STD_ITERATOR
+#undef HAVE_BI_ITERATOR
+#undef HAVE_FWD_ITERATOR
/* Indicates which slist we should use */
#undef HAVE_EXT_SLIST
From vadve at cs.uiuc.edu Tue Jul 29 14:33:01 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 14:33:01 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/FunctionLiveVarInfo.h
Message-ID: <200307291932.OAA04453@psmith.cs.uiuc.edu>
Changes in directory llvm/include/llvm/CodeGen:
FunctionLiveVarInfo.h updated: 1.26 -> 1.27
---
Log message:
Don't require a BB to look-up live variables, unless they may need to
be recomputed.
---
Diffs of the changes:
Index: llvm/include/llvm/CodeGen/FunctionLiveVarInfo.h
diff -u llvm/include/llvm/CodeGen/FunctionLiveVarInfo.h:1.26 llvm/include/llvm/CodeGen/FunctionLiveVarInfo.h:1.27
--- llvm/include/llvm/CodeGen/FunctionLiveVarInfo.h:1.26 Tue Jan 14 16:56:12 2003
+++ llvm/include/llvm/CodeGen/FunctionLiveVarInfo.h Tue Jul 29 14:32:04 2003
@@ -110,13 +110,17 @@
// gets InSet of a BB
const ValueSet &getInSetOfBB(const BasicBlock *BB) const;
- // gets the Live var set BEFORE an instruction
+ // gets the Live var set BEFORE an instruction.
+ // if BB is specified and the live var set has not yet been computed,
+ // it will be computed on demand.
const ValueSet &getLiveVarSetBeforeMInst(const MachineInstr *MI,
- const BasicBlock *BB);
+ const BasicBlock *BB = 0);
// gets the Live var set AFTER an instruction
+ // if BB is specified and the live var set has not yet been computed,
+ // it will be computed on demand.
const ValueSet &getLiveVarSetAfterMInst(const MachineInstr *MI,
- const BasicBlock *BB);
+ const BasicBlock *BB = 0);
};
#endif
From vadve at cs.uiuc.edu Tue Jul 29 14:38:01 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 14:38:01 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/PhyRegAlloc.h
Message-ID: <200307291937.OAA04525@psmith.cs.uiuc.edu>
Changes in directory llvm/include/llvm/CodeGen:
PhyRegAlloc.h updated: 1.43 -> 1.44
---
Log message:
Code to insert caller-saves moved here from SparcRegInfo: it is now
machine-independent.
Fix problem with using branch operand reg. as temp. reg. when
spilling values used by an instruction in the delay slot of the branch
(which will eventually be moved before the branch).
---
Diffs of the changes:
Index: llvm/include/llvm/CodeGen/PhyRegAlloc.h
diff -u llvm/include/llvm/CodeGen/PhyRegAlloc.h:1.43 llvm/include/llvm/CodeGen/PhyRegAlloc.h:1.44
--- llvm/include/llvm/CodeGen/PhyRegAlloc.h:1.43 Fri Jul 25 16:00:13 2003
+++ llvm/include/llvm/CodeGen/PhyRegAlloc.h Tue Jul 29 14:37:41 2003
@@ -20,6 +20,7 @@
#define PHY_REG_ALLOC_H
#include "llvm/CodeGen/LiveRangeInfo.h"
+#include "llvm/CodeGen/MachineBasicBlock.h"
#include "Support/NonCopyable.h"
#include
@@ -81,7 +82,6 @@
//
void allocateRegisters();
-
// access to register classes by class ID
//
const RegClass* getRegClassByID(unsigned int id) const {
@@ -90,7 +90,7 @@
RegClass* getRegClassByID(unsigned int id) {
return RegClassList[id];
}
-
+
private:
void addInterference(const Value *Def, const ValueSet *LVSet,
bool isCallInst);
@@ -109,32 +109,45 @@
void allocateStackSpace4SpilledLRs();
void insertCode4SpilledLR (const LiveRange *LR,
- MachineInstr *MInst,
- const BasicBlock *BB,
+ MachineBasicBlock::iterator& MII,
+ MachineBasicBlock &MBB,
const unsigned OpNum);
+ // Method for inserting caller saving code. The caller must save all the
+ // volatile registers live across a call.
+ void insertCallerSavingCode(std::vector& instrnsBefore,
+ std::vector& instrnsAfter,
+ MachineInstr *CallMI,
+ const BasicBlock *BB);
+
inline void constructLiveRanges() { LRI.constructLiveRanges(); }
void colorIncomingArgs();
void colorCallRetArgs();
void updateMachineCode();
- void updateInstruction(MachineInstr* MInst, BasicBlock* BB);
+ void updateInstruction(MachineBasicBlock::iterator& MII,
+ MachineBasicBlock &MBB);
void printLabel(const Value *const Val);
void printMachineCode();
- friend class UltraSparcRegInfo; // FIXME: remove this
-
int getUsableUniRegAtMI(int RegType,
const ValueSet *LVSetBef,
MachineInstr *MInst,
std::vector& MIBef,
std::vector& MIAft);
+ // Callback method used to find unused registers.
+ // LVSetBef is the live variable set to search for an unused register.
+ // If it is not specified, the LV set before the current MInst is used.
+ // This is sufficient as long as no new copy instructions are generated
+ // to copy the free register to memory.
+ //
int getUnusedUniRegAtMI(RegClass *RC, const int RegType,
- const MachineInstr *MInst, const ValueSet *LVSetBef);
-
+ const MachineInstr *MInst,
+ const ValueSet *LVSetBef = 0);
+
void setRelRegsUsedByThisInst(RegClass *RC, const int RegType,
const MachineInstr *MInst );
From vadve at cs.uiuc.edu Tue Jul 29 14:39:01 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 14:39:01 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveRangeInfo.h
Message-ID: <200307291938.OAA04544@psmith.cs.uiuc.edu>
Changes in directory llvm/include/llvm/CodeGen:
LiveRangeInfo.h updated: 1.17 -> 1.18
---
Log message:
Add const version of getLiveRangeForValue().
---
Diffs of the changes:
Index: llvm/include/llvm/CodeGen/LiveRangeInfo.h
diff -u llvm/include/llvm/CodeGen/LiveRangeInfo.h:1.17 llvm/include/llvm/CodeGen/LiveRangeInfo.h:1.18
--- llvm/include/llvm/CodeGen/LiveRangeInfo.h:1.17 Sat Jul 26 17:59:45 2003
+++ llvm/include/llvm/CodeGen/LiveRangeInfo.h Tue Jul 29 14:38:22 2003
@@ -92,10 +92,15 @@
inline const LiveRangeMapType *getLiveRangeMap() const
{ return &LiveRangeMap; }
- // Method sed to get the corresponding live range of a Value
- //
- inline LiveRange *getLiveRangeForValue( const Value *Val)
- { return LiveRangeMap[Val]; }
+ // Method used to get the live range containing a Value.
+ // This may return NULL if no live range exists for a Value (eg, some consts)
+ inline LiveRange *getLiveRangeForValue(const Value *Val) {
+ return LiveRangeMap[Val];
+ }
+ inline const LiveRange *getLiveRangeForValue(const Value *Val) const {
+ LiveRangeMapType::const_iterator I = LiveRangeMap.find(Val);
+ return I->second;
+ }
// Method for coalescing live ranges. Called only after interference info
// is calculated.
From vadve at cs.uiuc.edu Tue Jul 29 14:42:00 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 14:42:00 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetRegInfo.h
Message-ID: <200307291941.OAA04570@psmith.cs.uiuc.edu>
Changes in directory llvm/include/llvm/Target:
TargetRegInfo.h updated: 1.43 -> 1.44
---
Log message:
Moved insertCallerSavingCode() to PhyRegAlloc and
moved isRegVolatile and modifiedByCall here: they are all
machine independent. Remove all uses of PhyRegAlloc.
---
Diffs of the changes:
Index: llvm/include/llvm/Target/TargetRegInfo.h
diff -u llvm/include/llvm/Target/TargetRegInfo.h:1.43 llvm/include/llvm/Target/TargetRegInfo.h:1.44
--- llvm/include/llvm/Target/TargetRegInfo.h:1.43 Fri Jul 25 16:01:43 2003
+++ llvm/include/llvm/Target/TargetRegInfo.h Tue Jul 29 14:41:23 2003
@@ -21,7 +21,6 @@
class LiveRange;
class AddedInstrns;
class MachineInstr;
-class PhyRegAlloc;
class BasicBlock;
///----------------------------------------------------------------------------
@@ -75,9 +74,12 @@
virtual void colorIGNode(IGNode *Node,
const std::vector &IsColorUsedArr) const = 0;
+ // Check whether a specific register is volatile, i.e., whether it is not
+ // preserved across calls
virtual bool isRegVolatile(int Reg) const = 0;
- // If any specific register needs extra information
+ // Check whether a specific register is modified as a side-effect of the
+ // call instruction itself,
virtual bool modifiedByCall(int Reg) const {return false; }
virtual const char* const getRegName(unsigned reg) const = 0;
@@ -151,27 +153,18 @@
// as required. See SparcRegInfo.cpp for the implementation for Sparc.
//
virtual void suggestRegs4MethodArgs(const Function *Func,
- LiveRangeInfo &LRI) const = 0;
+ LiveRangeInfo& LRI) const = 0;
virtual void suggestRegs4CallArgs(MachineInstr *CallI,
- LiveRangeInfo &LRI) const = 0;
+ LiveRangeInfo& LRI) const = 0;
virtual void suggestReg4RetValue(MachineInstr *RetI,
- LiveRangeInfo &LRI) const = 0;
+ LiveRangeInfo& LRI) const = 0;
- virtual void colorMethodArgs(const Function *Func, LiveRangeInfo &LRI,
- AddedInstrns *FirstAI) const = 0;
-
- // Method for inserting caller saving code. The caller must save all the
- // volatile registers across a call based on the calling conventions of
- // an architecture. This must insert code for saving and restoring
- // such registers on
- //
- virtual void insertCallerSavingCode(std::vector& instrnsBefore,
- std::vector& instrnsAfter,
- MachineInstr *CallMI,
- const BasicBlock *BB,
- PhyRegAlloc &PRA) const = 0;
+ virtual void colorMethodArgs(const Function *Func,
+ LiveRangeInfo &LRI,
+ std::vector& InstrnsBefore,
+ std::vector& InstrnsAfter) const = 0;
// The following methods are used to generate "copy" machine instructions
// for an architecture. Currently they are used in TargetRegClass
@@ -204,7 +197,17 @@
virtual void cpValue2Value(Value *Src, Value *Dest,
std::vector& mvec) const = 0;
- virtual bool isRegVolatile(int RegClassID, int Reg) const = 0;
+ // Check whether a specific register is volatile, i.e., whether it is not
+ // preserved across calls
+ inline virtual bool isRegVolatile(int RegClassID, int Reg) const {
+ return MachineRegClassArr[RegClassID]->isRegVolatile(Reg);
+ }
+
+ // Check whether a specific register is modified as a side-effect of the
+ // call instruction itself,
+ inline virtual bool modifiedByCall(int RegClassID, int Reg) const {
+ return MachineRegClassArr[RegClassID]->modifiedByCall(Reg);
+ }
// Returns the reg used for pushing the address when a method is called.
// This can be used for other purposes between calls
From vadve at cs.uiuc.edu Tue Jul 29 14:43:01 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 14:43:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
Message-ID: <200307291942.OAA04587@psmith.cs.uiuc.edu>
Changes in directory llvm/lib/Analysis/LiveVar:
FunctionLiveVarInfo.cpp updated: 1.43 -> 1.44
---
Log message:
Don't require a BB to look-up live variables, unless they may need to
be recomputed.
---
Diffs of the changes:
Index: llvm/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
diff -u llvm/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp:1.43 llvm/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp:1.44
--- llvm/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp:1.43 Mon May 26 19:06:00 2003
+++ llvm/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp Tue Jul 29 14:42:32 2003
@@ -180,28 +180,29 @@
const ValueSet &
FunctionLiveVarInfo::getLiveVarSetBeforeMInst(const MachineInstr *MInst,
const BasicBlock *BB) {
- if (const ValueSet *LVSet = MInst2LVSetBI[MInst]) {
- return *LVSet; // if found, just return the set
- } else {
- calcLiveVarSetsForBB(BB); // else, calc for all instrs in BB
- return *MInst2LVSetBI[MInst];
+ const ValueSet *LVSet = MInst2LVSetBI[MInst];
+ if (LVSet == NULL && BB != NULL) { // if not found and BB provided
+ calcLiveVarSetsForBB(BB); // calc LVSet for all instrs in BB
+ LVSet = MInst2LVSetBI[MInst];
}
+ return *LVSet;
}
//-----------------------------------------------------------------------------
// Gives live variable information after a machine instruction
//-----------------------------------------------------------------------------
+
const ValueSet &
FunctionLiveVarInfo::getLiveVarSetAfterMInst(const MachineInstr *MI,
const BasicBlock *BB) {
- if (const ValueSet *LVSet = MInst2LVSetAI[MI]) {
- return *LVSet; // if found, just return the set
- } else {
- calcLiveVarSetsForBB(BB); // else, calc for all instrs in BB
+ const ValueSet *LVSet = MInst2LVSetAI[MI];
+ if (LVSet == NULL && BB != NULL) { // if not found and BB provided
+ calcLiveVarSetsForBB(BB); // calc LVSet for all instrs in BB
return *MInst2LVSetAI[MI];
}
+ return *LVSet;
}
// This function applies a machine instr to a live var set (accepts OutSet) and
From vadve at cs.uiuc.edu Tue Jul 29 14:50:02 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 14:50:02 2003
Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
Message-ID: <200307291949.OAA04618@psmith.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/RegAlloc:
PhyRegAlloc.cpp updated: 1.100 -> 1.101
---
Log message:
1. Bug fix: Don't use branch operand reg. as temp. reg. when
spilling values used by an instruction in the delay slot of the branch
(which will eventually be moved before the branch).
2. Bug fix: Delete the delay slot instr, not the branch instr, when
moving delay slot instr. out!!!!
3. Move code to insert caller-saves moved here from SparcRegInfo:
it is now machine-independent.
---
Diffs of the changes:
Index: llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
diff -u llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.100 llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.101
--- llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.100 Sat Jul 26 18:29:51 2003
+++ llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp Tue Jul 29 14:49:21 2003
@@ -14,6 +14,7 @@
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionInfo.h"
#include "llvm/CodeGen/FunctionLiveVarInfo.h"
+#include "llvm/CodeGen/InstrSelection.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetFrameInfo.h"
@@ -489,13 +490,12 @@
}
}
-void PhyRegAlloc::updateInstruction(MachineInstr* MInst, BasicBlock* BB)
+static bool MarkAllocatedRegs(MachineInstr* MInst,
+ LiveRangeInfo& LRI,
+ const TargetRegInfo& MRI)
{
- unsigned Opcode = MInst->getOpCode();
-
- // Reset tmp stack positions so they can be reused for each machine instr.
- MF.getInfo()->popAllTempValues();
-
+ bool instrNeedsSpills = false;
+
// First, set the registers for operands in the machine instruction
// if a register was successfully allocated. Do this first because we
// will need to know which registers are already used by this instr'n.
@@ -507,19 +507,41 @@
Op.getType() == MachineOperand::MO_CCRegister)
{
const Value *const Val = Op.getVRegValue();
- if (const LiveRange* LR = LRI.getLiveRangeForValue(Val))
+ if (const LiveRange* LR = LRI.getLiveRangeForValue(Val)) {
+ // Remember if any operand needs spilling
+ instrNeedsSpills |= LR->isMarkedForSpill();
+
+ // An operand may have a color whether or not it needs spilling
if (LR->hasColor())
MInst->SetRegForOperand(OpNum,
MRI.getUnifiedRegNum(LR->getRegClass()->getID(),
LR->getColor()));
+ }
}
} // for each operand
-
- // Mark that the operands have been updated. setRelRegsUsedByThisInst()
- // is called to find registers used by each MachineInst, and it should not
- // be used for an instruction until this is done. This flag just serves
- // as a sanity check.
+
+ return instrNeedsSpills;
+}
+
+void PhyRegAlloc::updateInstruction(MachineBasicBlock::iterator& MII,
+ MachineBasicBlock &MBB)
+{
+ MachineInstr* MInst = *MII;
+ unsigned Opcode = MInst->getOpCode();
+
+ // Reset tmp stack positions so they can be reused for each machine instr.
+ MF.getInfo()->popAllTempValues();
+
+ // Mark the operands for which regs have been allocated.
+ bool instrNeedsSpills = MarkAllocatedRegs(*MII, LRI, MRI);
+
+#ifndef NDEBUG
+ // Mark that the operands have been updated. Later,
+ // setRelRegsUsedByThisInst() is called to find registers used by each
+ // MachineInst, and it should not be used for an instruction until
+ // this is done. This flag just serves as a sanity check.
OperandsColoredMap[MInst] = true;
+#endif
// Now insert caller-saving code before/after the call.
// Do this before inserting spill code since some registers must be
@@ -527,25 +549,26 @@
//
if (TM.getInstrInfo().isCall(Opcode)) {
AddedInstrns &AI = AddedInstrMap[MInst];
- MRI.insertCallerSavingCode(AI.InstrnsBefore, AI.InstrnsAfter,
- MInst, BB, *this);
+ insertCallerSavingCode(AI.InstrnsBefore, AI.InstrnsAfter, MInst,
+ MBB.getBasicBlock());
}
// Now insert spill code for remaining operands not allocated to
// registers. This must be done even for call return instructions
// since those are not handled by the special code above.
- for (unsigned OpNum=0; OpNum < MInst->getNumOperands(); ++OpNum)
- {
- MachineOperand& Op = MInst->getOperand(OpNum);
- if (Op.getType() == MachineOperand::MO_VirtualRegister ||
- Op.getType() == MachineOperand::MO_CCRegister)
- {
- const Value* Val = Op.getVRegValue();
- if (const LiveRange *LR = LRI.getLiveRangeForValue(Val))
- if (LR->isMarkedForSpill())
- insertCode4SpilledLR(LR, MInst, BB, OpNum);
- }
- } // for each operand
+ if (instrNeedsSpills)
+ for (unsigned OpNum=0; OpNum < MInst->getNumOperands(); ++OpNum)
+ {
+ MachineOperand& Op = MInst->getOperand(OpNum);
+ if (Op.getType() == MachineOperand::MO_VirtualRegister ||
+ Op.getType() == MachineOperand::MO_CCRegister)
+ {
+ const Value* Val = Op.getVRegValue();
+ if (const LiveRange *LR = LRI.getLiveRangeForValue(Val))
+ if (LR->isMarkedForSpill())
+ insertCode4SpilledLR(LR, MII, MBB, OpNum);
+ }
+ } // for each operand
}
void PhyRegAlloc::updateMachineCode()
@@ -566,10 +589,9 @@
// Iterate over all machine instructions in BB and mark operands with
// their assigned registers or insert spill code, as appropriate.
// Also, fix operands of call/return instructions.
- //
for (MachineBasicBlock::iterator MII = MBB.begin(); MII != MBB.end(); ++MII)
- if (!TM.getInstrInfo().isDummyPhiInstr((*MII)->getOpCode()))// ignore Phis
- updateInstruction(*MII, const_cast(MBB.getBasicBlock()));
+ if (! TM.getInstrInfo().isDummyPhiInstr((*MII)->getOpCode()))
+ updateInstruction(MII, MBB);
// Now, move code out of delay slots of branches and returns if needed.
// (Also, move "after" code from calls to the last delay slot instruction.)
@@ -591,50 +613,48 @@
if (unsigned delaySlots =
TM.getInstrInfo().getNumDelaySlots((*MII)->getOpCode()))
{
- assert(delaySlots==1 && "Not handling multiple delay slots!");
-
- MachineInstr *MInst = *MII;
- MachineInstr *MDelayInst = *(MII+1);
-
+ MachineInstr *MInst = *MII, *DelaySlotMI = *(MII+1);
+
// Check the 2 conditions above:
// (1) Does a branch need instructions added after it?
// (2) O/w does delay slot instr. need instrns before or after?
- bool isBranch = (TM.getInstrInfo().isBranch((*MII)->getOpCode()) ||
- TM.getInstrInfo().isReturn((*MII)->getOpCode()));
- bool cond1 = isBranch && AddedInstrMap[MInst].InstrnsAfter.size() > 0;
- bool cond2 = (AddedInstrMap.count(MDelayInst) ||
- AddedInstrMap[MDelayInst].InstrnsAfter.size() > 0);
+ bool isBranch = (TM.getInstrInfo().isBranch(MInst->getOpCode()) ||
+ TM.getInstrInfo().isReturn(MInst->getOpCode()));
+ bool cond1 = (isBranch &&
+ AddedInstrMap.count(MInst) &&
+ AddedInstrMap[MInst].InstrnsAfter.size() > 0);
+ bool cond2 = (AddedInstrMap.count(DelaySlotMI) &&
+ (AddedInstrMap[DelaySlotMI].InstrnsBefore.size() > 0 ||
+ AddedInstrMap[DelaySlotMI].InstrnsAfter.size() > 0));
if (cond1 || cond2)
{
- // Move delay slot instrn before the preceding branch.
- // InsertBefore() modifies MII to point to the branch again.
- assert(((*MII)->getOpCodeFlags() & AnnulFlag) == 0 &&
- "FIXME: Annul bit must be turned off here!");
- InsertBefore(MDelayInst, MBB, MII);
+ assert((MInst->getOpCodeFlags() & AnnulFlag) == 0 &&
+ "FIXME: Moving an annulled delay slot instruction!");
+ assert(delaySlots==1 &&
+ "InsertBefore does not yet handle >1 delay slots!");
+ InsertBefore(DelaySlotMI, MBB, MII); // MII pts back to branch
// In case (1), delete it and don't replace with anything!
// Otherwise (i.e., case (2) only) replace it with a NOP.
if (cond1) {
- assert(AddedInstrMap[MInst].InstrnsAfter.size() <= delaySlots &&
- "Cannot put more than #delaySlots spill instrns after "
- "branch or return! Need to handle spill differently.");
- DeleteInstruction(MBB, MII); // MII now points to next inst.
+ DeleteInstruction(MBB, ++MII); // MII now points to next inst.
+ --MII; // reset MII for ++MII of loop
}
- else {
- MachineInstr* nopI =BuildMI(TM.getInstrInfo().getNOPOpCode(),1);
- SubstituteInPlace(nopI, MBB, MII+1); // replace with NOP
+ else
+ SubstituteInPlace(BuildMI(TM.getInstrInfo().getNOPOpCode(),1),
+ MBB, MII+1); // replace with NOP
+
+ if (DEBUG_RA) {
+ cerr << "\nRegAlloc: Moved instr. with added code: "
+ << *DelaySlotMI
+ << " out of delay slots of instr: " << *MInst;
}
}
-
- // If this is not a branch or return (probably a call),
- // the Instrnsafter, if any, must really go after the last
- // delay slot. Move the InstrAfter to the instr. in that slot.
- // We must do this after the previous code because the instructions
- // in delay slots may get moved out by that code.
- //
- if (!isBranch)
- move2DelayedInstr(MInst, *(MII+delaySlots));
+ else
+ // For non-branch instr with delay slots (probably a call), move
+ // InstrAfter to the instr. in the last delay slot.
+ move2DelayedInstr(*MII, *(MII+delaySlots));
}
// Finally iterate over all instructions in BB and insert before/after
@@ -651,6 +671,16 @@
AddedInstrns &CallAI = AddedInstrMap[MInst];
#ifndef NDEBUG
+ bool isBranch = (TM.getInstrInfo().isBranch(MInst->getOpCode()) ||
+ TM.getInstrInfo().isReturn(MInst->getOpCode()));
+ assert((!isBranch ||
+ AddedInstrMap[MInst].InstrnsAfter.size() <=
+ TM.getInstrInfo().getNumDelaySlots(MInst->getOpCode())) &&
+ "Cannot put more than #delaySlots instrns after "
+ "branch or return! Need to handle temps differently.");
+#endif
+
+#ifndef NDEBUG
// Temporary sanity checking code to detect whether the same machine
// instruction is ever inserted twice before/after a call.
// I suspect this is happening but am not sure. --Vikram, 7/1/03.
@@ -681,6 +711,7 @@
} // if there are any added instructions
} // for each machine instruction
+
}
}
@@ -696,10 +727,13 @@
//----------------------------------------------------------------------------
void PhyRegAlloc::insertCode4SpilledLR(const LiveRange *LR,
- MachineInstr *MInst,
- const BasicBlock *BB,
+ MachineBasicBlock::iterator& MII,
+ MachineBasicBlock &MBB,
const unsigned OpNum) {
+ MachineInstr *MInst = *MII;
+ const BasicBlock *BB = MBB.getBasicBlock();
+
assert((! TM.getInstrInfo().isCall(MInst->getOpCode()) || OpNum == 0) &&
"Outgoing arg of a call must be handled elsewhere (func arg ok)");
assert(! TM.getInstrInfo().isReturn(MInst->getOpCode()) &&
@@ -711,7 +745,20 @@
unsigned RegType = MRI.getRegTypeForLR(LR);
int SpillOff = LR->getSpillOffFromFP();
RegClass *RC = LR->getRegClass();
- const ValueSet &LVSetBef = LVI->getLiveVarSetBeforeMInst(MInst, BB);
+
+ // Get the live-variable set to find registers free before this instr.
+ // If this instr. is in the delay slot of a branch or return, use the live
+ // var set before that branch or return -- we don't want to trample those!
+ //
+ MachineInstr *LiveBeforeThisMI = MInst;
+ if (MII != MBB.begin()) {
+ MachineInstr *PredMI = *(MII-1);
+ if (unsigned DS = TM.getInstrInfo().getNumDelaySlots(PredMI->getOpCode())) {
+ assert(DS == 1 && "Only checking immediate pred. for delay slots!");
+ LiveBeforeThisMI = PredMI;
+ }
+ }
+ const ValueSet &LVSetBef = LVI->getLiveVarSetBeforeMInst(LiveBeforeThisMI,BB);
MF.getInfo()->pushTempValue(MRI.getSpilledRegSize(RegType) );
@@ -751,8 +798,8 @@
// and use the TmpReg as one operand of instruction
// actual loading instruction(s)
- MRI.cpMem2RegMI(AdIMid, MRI.getFramePointer(), SpillOff, TmpRegU, RegType,
- scratchReg);
+ MRI.cpMem2RegMI(AdIMid, MRI.getFramePointer(), SpillOff, TmpRegU,
+ RegType, scratchReg);
// the actual load should be after the instructions to free up TmpRegU
MIBef.insert(MIBef.end(), AdIMid.begin(), AdIMid.end());
@@ -764,8 +811,8 @@
// on the stack position allocated for this LR
// actual storing instruction(s)
- MRI.cpReg2MemMI(AdIMid, TmpRegU, MRI.getFramePointer(), SpillOff, RegType,
- scratchReg);
+ MRI.cpReg2MemMI(AdIMid, TmpRegU, MRI.getFramePointer(), SpillOff,
+ RegType, scratchReg);
MIAft.insert(MIAft.begin(), AdIMid.begin(), AdIMid.end());
} // if !DEF
@@ -784,6 +831,195 @@
}
+
+//----------------------------------------------------------------------------
+// This method inserts caller saving/restoring instructons before/after
+// a call machine instruction. The caller saving/restoring instructions are
+// inserted like:
+// ** caller saving instructions
+// other instructions inserted for the call by ColorCallArg
+// CALL instruction
+// other instructions inserted for the call ColorCallArg
+// ** caller restoring instructions
+//----------------------------------------------------------------------------
+
+void
+PhyRegAlloc::insertCallerSavingCode(std::vector &instrnsBefore,
+ std::vector &instrnsAfter,
+ MachineInstr *CallMI,
+ const BasicBlock *BB)
+{
+ assert(TM.getInstrInfo().isCall(CallMI->getOpCode()));
+
+ // has set to record which registers were saved/restored
+ //
+ hash_set PushedRegSet;
+
+ CallArgsDescriptor* argDesc = CallArgsDescriptor::get(CallMI);
+
+ // if the call is to a instrumentation function, do not insert save and
+ // restore instructions the instrumentation function takes care of save
+ // restore for volatile regs.
+ //
+ // FIXME: this should be made general, not specific to the reoptimizer!
+ //
+ const Function *Callee = argDesc->getCallInst()->getCalledFunction();
+ bool isLLVMFirstTrigger = Callee && Callee->getName() == "llvm_first_trigger";
+
+ // Now check if the call has a return value (using argDesc) and if so,
+ // find the LR of the TmpInstruction representing the return value register.
+ // (using the last or second-last *implicit operand* of the call MI).
+ // Insert it to to the PushedRegSet since we must not save that register
+ // and restore it after the call.
+ // We do this because, we look at the LV set *after* the instruction
+ // to determine, which LRs must be saved across calls. The return value
+ // of the call is live in this set - but we must not save/restore it.
+ //
+ if (const Value *origRetVal = argDesc->getReturnValue()) {
+ unsigned retValRefNum = (CallMI->getNumImplicitRefs() -
+ (argDesc->getIndirectFuncPtr()? 1 : 2));
+ const TmpInstruction* tmpRetVal =
+ cast(CallMI->getImplicitRef(retValRefNum));
+ assert(tmpRetVal->getOperand(0) == origRetVal &&
+ tmpRetVal->getType() == origRetVal->getType() &&
+ "Wrong implicit ref?");
+ LiveRange *RetValLR = LRI.getLiveRangeForValue(tmpRetVal);
+ assert(RetValLR && "No LR for RetValue of call");
+
+ if (! RetValLR->isMarkedForSpill())
+ PushedRegSet.insert(MRI.getUnifiedRegNum(RetValLR->getRegClassID(),
+ RetValLR->getColor()));
+ }
+
+ const ValueSet &LVSetAft = LVI->getLiveVarSetAfterMInst(CallMI, BB);
+ ValueSet::const_iterator LIt = LVSetAft.begin();
+
+ // for each live var in live variable set after machine inst
+ for( ; LIt != LVSetAft.end(); ++LIt) {
+
+ // get the live range corresponding to live var
+ LiveRange *const LR = LRI.getLiveRangeForValue(*LIt);
+
+ // LR can be null if it is a const since a const
+ // doesn't have a dominating def - see Assumptions above
+ if( LR ) {
+
+ if(! LR->isMarkedForSpill()) {
+
+ assert(LR->hasColor() && "LR is neither spilled nor colored?");
+ unsigned RCID = LR->getRegClassID();
+ unsigned Color = LR->getColor();
+
+ if (MRI.isRegVolatile(RCID, Color) ) {
+
+ //if the function is special LLVM function,
+ //And the register is not modified by call, don't save and restore
+ if (isLLVMFirstTrigger && !MRI.modifiedByCall(RCID, Color))
+ continue;
+
+ // if the value is in both LV sets (i.e., live before and after
+ // the call machine instruction)
+
+ unsigned Reg = MRI.getUnifiedRegNum(RCID, Color);
+
+ if( PushedRegSet.find(Reg) == PushedRegSet.end() ) {
+
+ // if we haven't already pushed that register
+
+ unsigned RegType = MRI.getRegTypeForLR(LR);
+
+ // Now get two instructions - to push on stack and pop from stack
+ // and add them to InstrnsBefore and InstrnsAfter of the
+ // call instruction
+ //
+ int StackOff =
+ MF.getInfo()->pushTempValue(MRI.getSpilledRegSize(RegType));
+
+ //---- Insert code for pushing the reg on stack ----------
+
+ std::vector AdIBef, AdIAft;
+
+ // We may need a scratch register to copy the saved value
+ // to/from memory. This may itself have to insert code to
+ // free up a scratch register. Any such code should go before
+ // the save code. The scratch register, if any, is by default
+ // temporary and not "used" by the instruction unless the
+ // copy code itself decides to keep the value in the scratch reg.
+ int scratchRegType = -1;
+ int scratchReg = -1;
+ if (MRI.regTypeNeedsScratchReg(RegType, scratchRegType))
+ { // Find a register not live in the LVSet before CallMI
+ const ValueSet &LVSetBef =
+ LVI->getLiveVarSetBeforeMInst(CallMI, BB);
+ scratchReg = getUsableUniRegAtMI(scratchRegType, &LVSetBef,
+ CallMI, AdIBef, AdIAft);
+ assert(scratchReg != MRI.getInvalidRegNum());
+ }
+
+ if (AdIBef.size() > 0)
+ instrnsBefore.insert(instrnsBefore.end(),
+ AdIBef.begin(), AdIBef.end());
+
+ MRI.cpReg2MemMI(instrnsBefore, Reg, MRI.getFramePointer(),
+ StackOff, RegType, scratchReg);
+
+ if (AdIAft.size() > 0)
+ instrnsBefore.insert(instrnsBefore.end(),
+ AdIAft.begin(), AdIAft.end());
+
+ //---- Insert code for popping the reg from the stack ----------
+
+ AdIBef.clear();
+ AdIAft.clear();
+
+ // We may need a scratch register to copy the saved value
+ // from memory. This may itself have to insert code to
+ // free up a scratch register. Any such code should go
+ // after the save code. As above, scratch is not marked "used".
+ //
+ scratchRegType = -1;
+ scratchReg = -1;
+ if (MRI.regTypeNeedsScratchReg(RegType, scratchRegType))
+ { // Find a register not live in the LVSet after CallMI
+ scratchReg = getUsableUniRegAtMI(scratchRegType, &LVSetAft,
+ CallMI, AdIBef, AdIAft);
+ assert(scratchReg != MRI.getInvalidRegNum());
+ }
+
+ if (AdIBef.size() > 0)
+ instrnsAfter.insert(instrnsAfter.end(),
+ AdIBef.begin(), AdIBef.end());
+
+ MRI.cpMem2RegMI(instrnsAfter, MRI.getFramePointer(), StackOff,
+ Reg, RegType, scratchReg);
+
+ if (AdIAft.size() > 0)
+ instrnsAfter.insert(instrnsAfter.end(),
+ AdIAft.begin(), AdIAft.end());
+
+ PushedRegSet.insert(Reg);
+
+ if(DEBUG_RA) {
+ std::cerr << "\nFor call inst:" << *CallMI;
+ std::cerr << " -inserted caller saving instrs: Before:\n\t ";
+ for_each(instrnsBefore.begin(), instrnsBefore.end(),
+ std::mem_fun(&MachineInstr::dump));
+ std::cerr << " -and After:\n\t ";
+ for_each(instrnsAfter.begin(), instrnsAfter.end(),
+ std::mem_fun(&MachineInstr::dump));
+ }
+ } // if not already pushed
+
+ } // if LR has a volatile color
+
+ } // if LR has color
+
+ } // if there is a LR for Var
+
+ } // for each value in the LV set after instruction
+}
+
+
//----------------------------------------------------------------------------
// We can use the following method to get a temporary register to be used
// BEFORE any given machine instruction. If there is a register available,
@@ -837,24 +1073,28 @@
return RegU;
}
+
//----------------------------------------------------------------------------
-// This method is called to get a new unused register that can be used to
-// accomodate a spilled value.
-// This method may be called several times for a single machine instruction
-// if it contains many spilled operands. Each time it is called, it finds
-// a register which is not live at that instruction and also which is not
-// used by other spilled operands of the same instruction.
-// Return register number is relative to the register class. NOT
-// unified number
+// This method is called to get a new unused register that can be used
+// to accomodate a temporary value. This method may be called several times
+// for a single machine instruction. Each time it is called, it finds a
+// register which is not live at that instruction and also which is not used
+// by other spilled operands of the same instruction. Return register number
+// is relative to the register class, NOT the unified number.
//----------------------------------------------------------------------------
int PhyRegAlloc::getUnusedUniRegAtMI(RegClass *RC,
const int RegType,
- const MachineInstr *MInst,
- const ValueSet *LVSetBef) {
+ const MachineInstr *MInst,
+ const ValueSet* LVSetBef) {
RC->clearColorsUsed(); // Reset array
-
+
+ if (LVSetBef == NULL) {
+ LVSetBef = &LVI->getLiveVarSetBeforeMInst(MInst);
+ assert(LVSetBef != NULL && "Unable to get live-var set before MInst?");
+ }
+
ValueSet::const_iterator LIt = LVSetBef->begin();
// for each live var in live variable set after machine inst
@@ -953,11 +1193,16 @@
void PhyRegAlloc::move2DelayedInstr(const MachineInstr *OrigMI,
const MachineInstr *DelayedMI)
{
+ if (DEBUG_RA) {
+ cerr << "\nRegAlloc: Moved InstrnsAfter for: " << *OrigMI;
+ cerr << " to last delay slot instrn: " << *DelayedMI;
+ }
+
// "added after" instructions of the original instr
std::vector &OrigAft = AddedInstrMap[OrigMI].InstrnsAfter;
// "added after" instructions of the delayed instr
- std::vector &DelayedAft =AddedInstrMap[DelayedMI].InstrnsAfter;
+ std::vector &DelayedAft=AddedInstrMap[DelayedMI].InstrnsAfter;
// go thru all the "added after instructions" of the original instruction
// and append them to the "added after instructions" of the delayed
@@ -1063,7 +1308,8 @@
//----------------------------------------------------------------------------
void PhyRegAlloc::colorIncomingArgs()
{
- MRI.colorMethodArgs(Fn, LRI, &AddedInstrAtEntry);
+ MRI.colorMethodArgs(Fn, LRI, AddedInstrAtEntry.InstrnsBefore,
+ AddedInstrAtEntry.InstrnsAfter);
}
@@ -1136,7 +1382,6 @@
}
} // for all LR's in hash map
}
-
//----------------------------------------------------------------------------
From vadve at cs.uiuc.edu Tue Jul 29 14:51:01 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 14:51:01 2003
Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp
Message-ID: <200307291950.OAA04636@psmith.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/InstrSelection:
InstrSelectionSupport.cpp updated: 1.54 -> 1.55
---
Log message:
All constant-evaluation code now unified into
TargetInstrInfo::ConvertConstantToIntType().
---
Diffs of the changes:
Index: llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp
diff -u llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.54 llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.55
--- llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.54 Wed Jul 23 10:17:51 2003
+++ llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp Tue Jul 29 14:50:12 2003
@@ -87,43 +87,20 @@
getImmedValue = 0;
// To use reg or immed, constant needs to be integer, bool, or a NULL pointer
- Constant *CPV = dyn_cast(val);
- if (CPV == NULL
- || CPV->isConstantExpr()
- || (! CPV->getType()->isIntegral() &&
- ! (isa(CPV->getType()) && CPV->isNullValue())))
+ // TargetInstrInfo::ConvertConstantToIntType() does the right conversions:
+ bool isValidConstant;
+ uint64_t valueToUse =
+ target.getInstrInfo().ConvertConstantToIntType(target, val, val->getType(),
+ isValidConstant);
+ if (! isValidConstant)
return MachineOperand::MO_VirtualRegister;
- // Now get the constant value and check if it fits in the IMMED field.
- // Take advantage of the fact that the max unsigned value will rarely
- // fit into any IMMED field and ignore that case (i.e., cast smaller
- // unsigned constants to signed).
+ // Now check if the constant value fits in the IMMED field.
//
- int64_t intValue;
- if (isa(CPV->getType()))
- intValue = 0; // We checked above that it is NULL
- else if (ConstantBool* CB = dyn_cast(CPV))
- intValue = CB->getValue();
- else if (CPV->getType()->isSigned())
- intValue = cast(CPV)->getValue();
- else
- { // get the int value and sign-extend if original was less than 64 bits
- intValue = cast(CPV)->getValue();
- switch(CPV->getType()->getPrimitiveID())
- {
- case Type::UByteTyID: intValue = (int64_t) (int8_t) intValue; break;
- case Type::UShortTyID: intValue = (int64_t) (short) intValue; break;
- case Type::UIntTyID: intValue = (int64_t) (int) intValue; break;
- default: break;
- }
- }
-
- return ChooseRegOrImmed(intValue, CPV->getType()->isSigned(),
+ return ChooseRegOrImmed((int64_t) valueToUse, val->getType()->isSigned(),
opCode, target, canUseImmed,
getMachineRegNum, getImmedValue);
}
-
-
//---------------------------------------------------------------------------
// Function: FixConstantOperandsForInstr
From vadve at cs.uiuc.edu Tue Jul 29 14:54:02 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 14:54:02 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcRegInfo.cpp
Message-ID: <200307291953.OAA04659@psmith.cs.uiuc.edu>
Changes in directory llvm/lib/Target/Sparc:
SparcRegInfo.cpp updated: 1.105 -> 1.106
---
Log message:
Add code to support stack spill/temp offsets that don't fit in the
immed. field. Moved insertCallerSavingCode() to PhyRegAlloc: it is
now machine independent. Remove all uses of PhyRegAlloc.
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/SparcRegInfo.cpp
diff -u llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.105 llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.106
--- llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.105 Fri Jul 25 16:12:15 2003
+++ llvm/lib/Target/Sparc/SparcRegInfo.cpp Tue Jul 29 14:53:21 2003
@@ -9,13 +9,11 @@
#include "SparcRegClassInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionInfo.h"
-#include "llvm/CodeGen/PhyRegAlloc.h"
#include "llvm/CodeGen/InstrSelection.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineCodeForInstruction.h"
#include "llvm/CodeGen/MachineInstrAnnot.h"
-#include "llvm/CodeGen/FunctionLiveVarInfo.h" // FIXME: Remove
-#include "../../CodeGen/RegAlloc/RegAllocCommon.h" // FIXME!
+#include "llvm/CodeGen/LiveRangeInfo.h"
#include "llvm/iTerminators.h"
#include "llvm/iOther.h"
#include "llvm/Function.h"
@@ -386,8 +384,9 @@
// (suggested) color through graph coloring.
//---------------------------------------------------------------------------
void UltraSparcRegInfo::colorMethodArgs(const Function *Meth,
- LiveRangeInfo &LRI,
- AddedInstrns *FirstAI) const {
+ LiveRangeInfo &LRI,
+ std::vector& InstrnsBefore,
+ std::vector& InstrnsAfter) const {
// check if this is a varArgs function. needed for choosing regs.
bool isVarArgs = isVarArgsFunction(Meth->getType());
@@ -454,14 +453,14 @@
int TmpOff = MachineFunction::get(Meth).getInfo()->pushTempValue(
getSpilledRegSize(regType));
- cpReg2MemMI(FirstAI->InstrnsBefore,
+ cpReg2MemMI(InstrnsBefore,
UniArgReg, getFramePointer(), TmpOff, IntRegType);
- cpMem2RegMI(FirstAI->InstrnsBefore,
+ cpMem2RegMI(InstrnsBefore,
getFramePointer(), TmpOff, UniLRReg, regType);
}
else {
- cpReg2RegMI(FirstAI->InstrnsBefore, UniArgReg, UniLRReg, regType);
+ cpReg2RegMI(InstrnsBefore, UniArgReg, UniLRReg, regType);
}
}
else {
@@ -484,7 +483,7 @@
offsetFromFP += slotSize - argSize;
}
- cpMem2RegMI(FirstAI->InstrnsBefore,
+ cpMem2RegMI(InstrnsBefore,
getFramePointer(), offsetFromFP, UniLRReg, regType);
}
@@ -510,11 +509,11 @@
assert(isVarArgs && regClassIDOfArgReg == IntRegClassID &&
"This should only be an Int register for an FP argument");
- cpReg2MemMI(FirstAI->InstrnsBefore, UniArgReg,
+ cpReg2MemMI(InstrnsBefore, UniArgReg,
getFramePointer(), LR->getSpillOffFromFP(), IntRegType);
}
else {
- cpReg2MemMI(FirstAI->InstrnsBefore, UniArgReg,
+ cpReg2MemMI(InstrnsBefore, UniArgReg,
getFramePointer(), LR->getSpillOffFromFP(), regType);
}
}
@@ -626,7 +625,7 @@
// values will be returned from this method and to suggest colors.
//---------------------------------------------------------------------------
void UltraSparcRegInfo::suggestReg4RetValue(MachineInstr *RetMI,
- LiveRangeInfo &LRI) const {
+ LiveRangeInfo& LRI) const {
assert( (target.getInstrInfo()).isReturn( RetMI->getOpCode() ) );
@@ -736,27 +735,51 @@
void
UltraSparcRegInfo::cpReg2MemMI(std::vector& mvec,
unsigned SrcReg,
- unsigned DestPtrReg,
+ unsigned PtrReg,
int Offset, int RegType,
int scratchReg) const {
MachineInstr * MI = NULL;
+ int OffReg = -1;
+
+ // If the Offset will not fit in the signed-immediate field, find an
+ // unused register to hold the offset value. This takes advantage of
+ // the fact that all the opcodes used below have the same size immed. field.
+ // Use the register allocator, PRA, to find an unused reg. at this MI.
+ //
+ if (RegType != IntCCRegType) // does not use offset below
+ if (! target.getInstrInfo().constantFitsInImmedField(V9::LDXi, Offset)) {
+#ifdef CAN_FIND_FREE_REGISTER_TRANSPARENTLY
+ RegClass* RC = PRA.getRegClassByID(this->getRegClassIDOfRegType(RegType));
+ OffReg = PRA.getUnusedUniRegAtMI(RC, RegType, MInst, LVSetBef);
+#else
+ // Default to using register g2 for holding large offsets
+ OffReg = getUnifiedRegNum(UltraSparcRegInfo::IntRegClassID,
+ SparcIntRegClass::g4);
+#endif
+ assert(OffReg >= 0 && "FIXME: cpReg2MemMI cannot find an unused reg.");
+ mvec.push_back(BuildMI(V9::SETSW, 2).addZImm(Offset).addReg(OffReg));
+ }
+
switch (RegType) {
case IntRegType:
- assert(target.getInstrInfo().constantFitsInImmedField(V9::STXi, Offset));
- MI = BuildMI(V9::STXi,3).addMReg(SrcReg).addMReg(DestPtrReg)
- .addSImm(Offset);
+ if (target.getInstrInfo().constantFitsInImmedField(V9::STXi, Offset))
+ MI = BuildMI(V9::STXi,3).addMReg(SrcReg).addMReg(PtrReg).addSImm(Offset);
+ else
+ MI = BuildMI(V9::STXr,3).addMReg(SrcReg).addMReg(PtrReg).addMReg(OffReg);
break;
case FPSingleRegType:
- assert(target.getInstrInfo().constantFitsInImmedField(V9::STFi, Offset));
- MI = BuildMI(V9::STFi, 3).addMReg(SrcReg).addMReg(DestPtrReg)
- .addSImm(Offset);
+ if (target.getInstrInfo().constantFitsInImmedField(V9::STFi, Offset))
+ MI = BuildMI(V9::STFi, 3).addMReg(SrcReg).addMReg(PtrReg).addSImm(Offset);
+ else
+ MI = BuildMI(V9::STFr, 3).addMReg(SrcReg).addMReg(PtrReg).addMReg(OffReg);
break;
case FPDoubleRegType:
- assert(target.getInstrInfo().constantFitsInImmedField(V9::STDFi, Offset));
- MI = BuildMI(V9::STDFi,3).addMReg(SrcReg).addMReg(DestPtrReg)
- .addSImm(Offset);
+ if (target.getInstrInfo().constantFitsInImmedField(V9::STDFi, Offset))
+ MI = BuildMI(V9::STDFi,3).addMReg(SrcReg).addMReg(PtrReg).addSImm(Offset);
+ else
+ MI = BuildMI(V9::STDFr,3).addMReg(SrcReg).addMReg(PtrReg).addSImm(OffReg);
break;
case IntCCRegType:
@@ -768,15 +791,16 @@
.addMReg(scratchReg, MOTy::Def));
mvec.push_back(MI);
- cpReg2MemMI(mvec, scratchReg, DestPtrReg, Offset, IntRegType);
+ cpReg2MemMI(mvec, scratchReg, PtrReg, Offset, IntRegType);
return;
-
+
case FloatCCRegType: {
- assert(target.getInstrInfo().constantFitsInImmedField(V9::STXFSRi, Offset));
- unsigned fsrRegNum = getUnifiedRegNum(UltraSparcRegInfo::SpecialRegClassID,
+ unsigned fsrReg = getUnifiedRegNum(UltraSparcRegInfo::SpecialRegClassID,
SparcSpecialRegClass::fsr);
- MI = BuildMI(V9::STXFSRi, 3)
- .addMReg(fsrRegNum).addMReg(DestPtrReg).addSImm(Offset);
+ if (target.getInstrInfo().constantFitsInImmedField(V9::STXFSRi, Offset))
+ MI=BuildMI(V9::STXFSRi,3).addMReg(fsrReg).addMReg(PtrReg).addSImm(Offset);
+ else
+ MI=BuildMI(V9::STXFSRr,3).addMReg(fsrReg).addMReg(PtrReg).addMReg(OffReg);
break;
}
default:
@@ -794,35 +818,65 @@
void
UltraSparcRegInfo::cpMem2RegMI(std::vector& mvec,
- unsigned SrcPtrReg,
+ unsigned PtrReg,
int Offset,
unsigned DestReg,
int RegType,
int scratchReg) const {
MachineInstr * MI = NULL;
+ int OffReg = -1;
+
+ // If the Offset will not fit in the signed-immediate field, find an
+ // unused register to hold the offset value. This takes advantage of
+ // the fact that all the opcodes used below have the same size immed. field.
+ // Use the register allocator, PRA, to find an unused reg. at this MI.
+ //
+ if (RegType != IntCCRegType) // does not use offset below
+ if (! target.getInstrInfo().constantFitsInImmedField(V9::LDXi, Offset)) {
+#ifdef CAN_FIND_FREE_REGISTER_TRANSPARENTLY
+ RegClass* RC = PRA.getRegClassByID(this->getRegClassIDOfRegType(RegType));
+ OffReg = PRA.getUnusedUniRegAtMI(RC, RegType, MInst, LVSetBef);
+#else
+ // Default to using register g2 for holding large offsets
+ OffReg = getUnifiedRegNum(UltraSparcRegInfo::IntRegClassID,
+ SparcIntRegClass::g4);
+#endif
+ assert(OffReg >= 0 && "FIXME: cpReg2MemMI cannot find an unused reg.");
+ mvec.push_back(BuildMI(V9::SETSW, 2).addZImm(Offset).addReg(OffReg));
+ }
+
switch (RegType) {
case IntRegType:
- assert(target.getInstrInfo().constantFitsInImmedField(V9::LDXi, Offset));
- MI = BuildMI(V9::LDXi, 3).addMReg(SrcPtrReg).addSImm(Offset)
- .addMReg(DestReg, MOTy::Def);
+ if (target.getInstrInfo().constantFitsInImmedField(V9::LDXi, Offset))
+ MI = BuildMI(V9::LDXi, 3).addMReg(PtrReg).addSImm(Offset).addMReg(DestReg,
+ MOTy::Def);
+ else
+ MI = BuildMI(V9::LDXr, 3).addMReg(PtrReg).addMReg(OffReg).addMReg(DestReg,
+ MOTy::Def);
break;
case FPSingleRegType:
- assert(target.getInstrInfo().constantFitsInImmedField(V9::LDFi, Offset));
- MI = BuildMI(V9::LDFi, 3).addMReg(SrcPtrReg).addSImm(Offset)
- .addMReg(DestReg, MOTy::Def);
+ if (target.getInstrInfo().constantFitsInImmedField(V9::LDFi, Offset))
+ MI = BuildMI(V9::LDFi, 3).addMReg(PtrReg).addSImm(Offset).addMReg(DestReg,
+ MOTy::Def);
+ else
+ MI = BuildMI(V9::LDFr, 3).addMReg(PtrReg).addMReg(OffReg).addMReg(DestReg,
+ MOTy::Def);
break;
case FPDoubleRegType:
- assert(target.getInstrInfo().constantFitsInImmedField(V9::LDDFi, Offset));
- MI = BuildMI(V9::LDDFi, 3).addMReg(SrcPtrReg).addSImm(Offset)
- .addMReg(DestReg, MOTy::Def);
+ if (target.getInstrInfo().constantFitsInImmedField(V9::LDDFi, Offset))
+ MI= BuildMI(V9::LDDFi, 3).addMReg(PtrReg).addSImm(Offset).addMReg(DestReg,
+ MOTy::Def);
+ else
+ MI= BuildMI(V9::LDDFr, 3).addMReg(PtrReg).addMReg(OffReg).addMReg(DestReg,
+ MOTy::Def);
break;
case IntCCRegType:
assert(scratchReg >= 0 && "Need scratch reg to load %ccr from memory");
assert(getRegType(scratchReg) ==IntRegType && "Invalid scratch reg");
- cpMem2RegMI(mvec, SrcPtrReg, Offset, scratchReg, IntRegType);
+ cpMem2RegMI(mvec, PtrReg, Offset, scratchReg, IntRegType);
MI = (BuildMI(V9::WRCCRr, 3)
.addMReg(scratchReg)
.addMReg(SparcIntRegClass::g0)
@@ -831,11 +885,14 @@
break;
case FloatCCRegType: {
- assert(target.getInstrInfo().constantFitsInImmedField(V9::LDXFSRi, Offset));
unsigned fsrRegNum = getUnifiedRegNum(UltraSparcRegInfo::SpecialRegClassID,
SparcSpecialRegClass::fsr);
- MI = BuildMI(V9::LDXFSRi, 3).addMReg(SrcPtrReg).addSImm(Offset)
- .addMReg(fsrRegNum, MOTy::UseAndDef);
+ if (target.getInstrInfo().constantFitsInImmedField(V9::LDXFSRi, Offset))
+ MI = BuildMI(V9::LDXFSRi, 3).addMReg(PtrReg).addSImm(Offset)
+ .addMReg(fsrRegNum, MOTy::UseAndDef);
+ else
+ MI = BuildMI(V9::LDXFSRr, 3).addMReg(PtrReg).addMReg(OffReg)
+ .addMReg(fsrRegNum, MOTy::UseAndDef);
break;
}
default:
@@ -875,202 +932,6 @@
mvec.push_back(MI);
}
-
-
-
-
-
-//----------------------------------------------------------------------------
-// This method inserts caller saving/restoring instructons before/after
-// a call machine instruction. The caller saving/restoring instructions are
-// inserted like:
-//
-// ** caller saving instructions
-// other instructions inserted for the call by ColorCallArg
-// CALL instruction
-// other instructions inserted for the call ColorCallArg
-// ** caller restoring instructions
-//
-//----------------------------------------------------------------------------
-
-
-void
-UltraSparcRegInfo::insertCallerSavingCode
-(std::vector &instrnsBefore,
- std::vector &instrnsAfter,
- MachineInstr *CallMI,
- const BasicBlock *BB,
- PhyRegAlloc &PRA) const
-{
- assert(target.getInstrInfo().isCall(CallMI->getOpCode()));
-
- // has set to record which registers were saved/restored
- //
- hash_set PushedRegSet;
-
- CallArgsDescriptor* argDesc = CallArgsDescriptor::get(CallMI);
-
- // if the call is to a instrumentation function, do not insert save and
- // restore instructions the instrumentation function takes care of save
- // restore for volatile regs.
- //
- // FIXME: this should be made general, not specific to the reoptimizer!
- //
- const Function *Callee = argDesc->getCallInst()->getCalledFunction();
- bool isLLVMFirstTrigger = Callee && Callee->getName() == "llvm_first_trigger";
-
- // Now check if the call has a return value (using argDesc) and if so,
- // find the LR of the TmpInstruction representing the return value register.
- // (using the last or second-last *implicit operand* of the call MI).
- // Insert it to to the PushedRegSet since we must not save that register
- // and restore it after the call.
- // We do this because, we look at the LV set *after* the instruction
- // to determine, which LRs must be saved across calls. The return value
- // of the call is live in this set - but we must not save/restore it.
- //
- if (const Value *origRetVal = argDesc->getReturnValue()) {
- unsigned retValRefNum = (CallMI->getNumImplicitRefs() -
- (argDesc->getIndirectFuncPtr()? 1 : 2));
- const TmpInstruction* tmpRetVal =
- cast(CallMI->getImplicitRef(retValRefNum));
- assert(tmpRetVal->getOperand(0) == origRetVal &&
- tmpRetVal->getType() == origRetVal->getType() &&
- "Wrong implicit ref?");
- LiveRange *RetValLR = PRA.LRI.getLiveRangeForValue( tmpRetVal );
- assert(RetValLR && "No LR for RetValue of call");
-
- if (! RetValLR->isMarkedForSpill())
- PushedRegSet.insert(getUnifiedRegNum(RetValLR->getRegClassID(),
- RetValLR->getColor()));
- }
-
- const ValueSet &LVSetAft = PRA.LVI->getLiveVarSetAfterMInst(CallMI, BB);
- ValueSet::const_iterator LIt = LVSetAft.begin();
-
- // for each live var in live variable set after machine inst
- for( ; LIt != LVSetAft.end(); ++LIt) {
-
- // get the live range corresponding to live var
- LiveRange *const LR = PRA.LRI.getLiveRangeForValue(*LIt );
-
- // LR can be null if it is a const since a const
- // doesn't have a dominating def - see Assumptions above
- if( LR ) {
-
- if(! LR->isMarkedForSpill()) {
-
- assert(LR->hasColor() && "LR is neither spilled nor colored?");
- unsigned RCID = LR->getRegClassID();
- unsigned Color = LR->getColor();
-
- if ( isRegVolatile(RCID, Color) ) {
-
- //if the function is special LLVM function,
- //And the register is not modified by call, don't save and restore
- if(isLLVMFirstTrigger && !modifiedByCall(RCID, Color))
- continue;
-
- // if the value is in both LV sets (i.e., live before and after
- // the call machine instruction)
-
- unsigned Reg = getUnifiedRegNum(RCID, Color);
-
- if( PushedRegSet.find(Reg) == PushedRegSet.end() ) {
-
- // if we haven't already pushed that register
-
- unsigned RegType = getRegTypeForLR(LR);
-
- // Now get two instructions - to push on stack and pop from stack
- // and add them to InstrnsBefore and InstrnsAfter of the
- // call instruction
- //
- int StackOff =
- PRA.MF.getInfo()->pushTempValue(getSpilledRegSize(RegType));
-
- //---- Insert code for pushing the reg on stack ----------
-
- std::vector AdIBef, AdIAft;
-
- // We may need a scratch register to copy the saved value
- // to/from memory. This may itself have to insert code to
- // free up a scratch register. Any such code should go before
- // the save code. The scratch register, if any, is by default
- // temporary and not "used" by the instruction unless the
- // copy code itself decides to keep the value in the scratch reg.
- int scratchRegType = -1;
- int scratchReg = -1;
- if (regTypeNeedsScratchReg(RegType, scratchRegType))
- { // Find a register not live in the LVSet before CallMI
- const ValueSet &LVSetBef =
- PRA.LVI->getLiveVarSetBeforeMInst(CallMI, BB);
- scratchReg = PRA.getUsableUniRegAtMI(scratchRegType, &LVSetBef,
- CallMI, AdIBef, AdIAft);
- assert(scratchReg != getInvalidRegNum());
- }
-
- if (AdIBef.size() > 0)
- instrnsBefore.insert(instrnsBefore.end(),
- AdIBef.begin(), AdIBef.end());
-
- cpReg2MemMI(instrnsBefore, Reg,getFramePointer(),StackOff,RegType,
- scratchReg);
-
- if (AdIAft.size() > 0)
- instrnsBefore.insert(instrnsBefore.end(),
- AdIAft.begin(), AdIAft.end());
-
- //---- Insert code for popping the reg from the stack ----------
-
- AdIBef.clear();
- AdIAft.clear();
-
- // We may need a scratch register to copy the saved value
- // from memory. This may itself have to insert code to
- // free up a scratch register. Any such code should go
- // after the save code. As above, scratch is not marked "used".
- //
- scratchRegType = -1;
- scratchReg = -1;
- if (regTypeNeedsScratchReg(RegType, scratchRegType))
- { // Find a register not live in the LVSet after CallMI
- scratchReg = PRA.getUsableUniRegAtMI(scratchRegType, &LVSetAft,
- CallMI, AdIBef, AdIAft);
- assert(scratchReg != getInvalidRegNum());
- }
-
- if (AdIBef.size() > 0)
- instrnsAfter.insert(instrnsAfter.end(),
- AdIBef.begin(), AdIBef.end());
-
- cpMem2RegMI(instrnsAfter, getFramePointer(), StackOff,Reg,RegType,
- scratchReg);
-
- if (AdIAft.size() > 0)
- instrnsAfter.insert(instrnsAfter.end(),
- AdIAft.begin(), AdIAft.end());
-
- PushedRegSet.insert(Reg);
-
- if(DEBUG_RA) {
- std::cerr << "\nFor call inst:" << *CallMI;
- std::cerr << " -inserted caller saving instrs: Before:\n\t ";
- for_each(instrnsBefore.begin(), instrnsBefore.end(),
- std::mem_fun(&MachineInstr::dump));
- std::cerr << " -and After:\n\t ";
- for_each(instrnsAfter.begin(), instrnsAfter.end(),
- std::mem_fun(&MachineInstr::dump));
- }
- } // if not already pushed
-
- } // if LR has a volatile color
-
- } // if LR has color
-
- } // if there is a LR for Var
-
- } // for each value in the LV set after instruction
-}
//---------------------------------------------------------------------------
From vadve at cs.uiuc.edu Tue Jul 29 14:55:01 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 14:55:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInternals.h
Message-ID: <200307291954.OAA04673@psmith.cs.uiuc.edu>
Changes in directory llvm/lib/Target/Sparc:
SparcInternals.h updated: 1.95 -> 1.96
---
Log message:
Add ConvertConstantToIntType() to unify all constant handling
that depends on machine register size.
Moved insertCallerSavingCode() to PhyRegAlloc and
moved isRegVolatile and modifiedByCall to TargetRegInfo: they are all
machine independent. Remove several dead functions.
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/SparcInternals.h
diff -u llvm/lib/Target/Sparc/SparcInternals.h:1.95 llvm/lib/Target/Sparc/SparcInternals.h:1.96
--- llvm/lib/Target/Sparc/SparcInternals.h:1.95 Fri Jul 25 16:12:15 2003
+++ llvm/lib/Target/Sparc/SparcInternals.h Tue Jul 29 14:54:41 2003
@@ -21,7 +21,6 @@
class LiveRange;
class UltraSparc;
-class PhyRegAlloc;
class Pass;
enum SparcInstrSchedClass {
@@ -158,6 +157,19 @@
//
virtual MachineOpCode getNOPOpCode() const { return V9::NOP; }
+ // Get the value of an integral constant in the form that must
+ // be put into the machine register. The specified constant is interpreted
+ // as (i.e., converted if necessary to) the specified destination type. The
+ // result is always returned as an uint64_t, since the representation of
+ // int64_t and uint64_t are identical. The argument can be any known const.
+ //
+ // isValidConstant is set to true if a valid constant was found.
+ //
+ virtual uint64_t ConvertConstantToIntType(const TargetMachine &target,
+ const Value *V,
+ const Type *destType,
+ bool &isValidConstant) const;
+
// Create an instruction sequence to put the constant `val' into
// the virtual register `dest'. `val' may be a Constant or a
// GlobalValue, viz., the constant address of a global variable or function.
@@ -271,35 +283,9 @@
void suggestReg4CallAddr(MachineInstr *CallMI, LiveRangeInfo &LRI) const;
- void InitializeOutgoingArg(MachineInstr* CallMI, AddedInstrns *CallAI,
- PhyRegAlloc &PRA, LiveRange* LR,
- unsigned regType, unsigned RegClassID,
- int UniArgReg, unsigned int argNo,
- std::vector& AddedInstrnsBefore)
- const;
-
// Helper used by the all the getRegType() functions.
int getRegTypeForClassAndType(unsigned regClassID, const Type* type) const;
- // Used to generate a copy instruction based on the register class of
- // value.
- //
- MachineInstr *cpValue2RegMI(Value *Val, unsigned DestReg,
- int RegType) const;
-
-
- // The following 2 methods are used to order the instructions addeed by
- // the register allocator in association with function calling. See
- // SparcRegInfo.cpp for more details
- //
- void moveInst2OrdVec(std::vector &OrdVec,
- MachineInstr *UnordInst,
- PhyRegAlloc &PRA) const;
-
- void OrderAddedInstrns(std::vector &UnordVec,
- std::vector &OrdVec,
- PhyRegAlloc &PRA) const;
-
public:
// Type of registers available in Sparc. There can be several reg types
// in the same class. For instace, the float reg class has Single/Double
@@ -382,16 +368,9 @@
void suggestReg4RetValue(MachineInstr *RetMI,
LiveRangeInfo& LRI) const;
- void colorMethodArgs(const Function *Meth, LiveRangeInfo &LRI,
- AddedInstrns *FirstAI) const;
-
- // This method inserts the caller saving code for call instructions
- //
- void insertCallerSavingCode(std::vector& instrnsBefore,
- std::vector& instrnsAfter,
- MachineInstr *CallMI,
- const BasicBlock *BB,
- PhyRegAlloc &PRA ) const;
+ void colorMethodArgs(const Function *Meth, LiveRangeInfo& LRI,
+ std::vector& InstrnsBefore,
+ std::vector& InstrnsAfter) const;
// method used for printing a register for debugging purposes
//
@@ -440,17 +419,6 @@
void cpValue2Value(Value *Src, Value *Dest,
std::vector& mvec) const;
- // To see whether a register is a volatile (i.e., whehter it must be
- // preserved acorss calls)
- //
- inline bool isRegVolatile(int RegClassID, int Reg) const {
- return MachineRegClassArr[RegClassID]->isRegVolatile(Reg);
- }
-
- inline bool modifiedByCall(int RegClassID, int Reg) const {
- return MachineRegClassArr[RegClassID]->modifiedByCall(Reg);
- }
-
// Get the register type for a register identified different ways.
// Note that getRegTypeForLR(LR) != getRegTypeForDataType(LR->getType())!
// The reg class of a LR depends both on the Value types in it and whether
@@ -726,8 +694,6 @@
// getEmitBytecodeToAsmPass - Emits final LLVM bytecode to assembly file.
Pass* getEmitBytecodeToAsmPass(std::ostream &Out);
};
-
-int64_t GetConstantValueAsSignedInt(const Value *V, bool &isValidConstant);
Pass *getFunctionInfo(std::ostream &out);
From vadve at cs.uiuc.edu Tue Jul 29 14:58:01 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 14:58:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/EmitAssembly.cpp
Message-ID: <200307291957.OAA04688@psmith.cs.uiuc.edu>
Changes in directory llvm/lib/Target/Sparc:
EmitAssembly.cpp updated: 1.84 -> 1.85
---
Log message:
Bug fix: don't unnecessarily pretty-print control-characters, some of
which were wrong (particularly, '\a' for '\007').
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/EmitAssembly.cpp
diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.84 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.85
--- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.84 Wed Jul 23 10:30:04 2003
+++ llvm/lib/Target/Sparc/EmitAssembly.cpp Tue Jul 29 14:57:34 2003
@@ -594,21 +594,10 @@
} else if (isprint(C)) {
Result += C;
} else {
- switch(C) {
- case '\a': Result += "\\a"; break;
- case '\b': Result += "\\b"; break;
- case '\f': Result += "\\f"; break;
- case '\n': Result += "\\n"; break;
- case '\r': Result += "\\r"; break;
- case '\t': Result += "\\t"; break;
- case '\v': Result += "\\v"; break;
- default:
- Result += '\\';
- Result += toOctal(C >> 6);
- Result += toOctal(C >> 3);
- Result += toOctal(C >> 0);
- break;
- }
+ Result += '\\'; // print all other chars as octal value
+ Result += toOctal(C >> 6);
+ Result += toOctal(C >> 3);
+ Result += toOctal(C >> 0);
}
}
Result += "\"";
From vadve at cs.uiuc.edu Tue Jul 29 14:59:01 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 14:59:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrInfo.cpp
Message-ID: <200307291958.OAA04716@psmith.cs.uiuc.edu>
Changes in directory llvm/lib/Target/Sparc:
SparcInstrInfo.cpp updated: 1.50 -> 1.51
---
Log message:
Unify all constant evaluations that depend on register size
in ConvertConstantToIntType.
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/SparcInstrInfo.cpp
diff -u llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.50 llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.51
--- llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.50 Wed Jul 23 10:22:19 2003
+++ llvm/lib/Target/Sparc/SparcInstrInfo.cpp Tue Jul 29 14:58:42 2003
@@ -20,47 +20,97 @@
//---------------------------------------------------------------------------
-// Function GetConstantValueAsUnsignedInt
-// Function GetConstantValueAsSignedInt
+// Function ConvertConstantToIntType
//
-// Convenience functions to get the value of an integral constant, for an
-// appropriate integer or non-integer type that can be held in a signed
-// or unsigned integer respectively. The type of the argument must be
-// the following:
-// Signed or unsigned integer
-// Boolean
-// Pointer
+// Function to get the value of an integral constant in the form
+// that must be put into the machine register. The specified constant is
+// interpreted as (i.e., converted if necessary to) the specified destination
+// type. The result is always returned as an uint64_t, since the representation
+// of int64_t and uint64_t are identical. The argument can be any known const.
//
// isValidConstant is set to true if a valid constant was found.
//---------------------------------------------------------------------------
-static uint64_t
-GetConstantValueAsUnsignedInt(const Value *V,
- bool &isValidConstant)
-{
- isValidConstant = true;
-
- if (isa(V))
- if (const ConstantBool *CB = dyn_cast(V))
- return (int64_t)CB->getValue();
- else if (const ConstantInt *CI = dyn_cast(V))
- return CI->getRawValue();
-
+uint64_t
+UltraSparcInstrInfo::ConvertConstantToIntType(const TargetMachine &target,
+ const Value *V,
+ const Type *destType,
+ bool &isValidConstant) const
+{
isValidConstant = false;
- return 0;
-}
+ uint64_t C = 0;
-int64_t
-GetConstantValueAsSignedInt(const Value *V, bool &isValidConstant)
-{
- uint64_t C = GetConstantValueAsUnsignedInt(V, isValidConstant);
+ if (! destType->isIntegral() && ! isa(destType))
+ return C;
+
+ if (! isa(V))
+ return C;
+
+ // ConstantPointerRef: no conversions needed: get value and return it
+ if (const ConstantPointerRef* CPR = dyn_cast(V)) {
+ // A ConstantPointerRef is just a reference to GlobalValue.
+ isValidConstant = true; // may be overwritten by recursive call
+ return (CPR->isNullValue()? 0
+ : ConvertConstantToIntType(target, CPR->getValue(), destType,
+ isValidConstant));
+ }
+
+ // ConstantBool: no conversions needed: get value and return it
+ if (const ConstantBool *CB = dyn_cast(V)) {
+ isValidConstant = true;
+ return (uint64_t) CB->getValue();
+ }
+
+ // For other types of constants, some conversion may be needed.
+ // First, extract the constant operand according to its own type
+ if (const ConstantExpr *CE = dyn_cast(V))
+ switch(CE->getOpcode()) {
+ case Instruction::Cast: // recursively get the value as cast
+ C = ConvertConstantToIntType(target, CE->getOperand(0), CE->getType(),
+ isValidConstant);
+ break;
+ default: // not simplifying other ConstantExprs
+ break;
+ }
+ else if (const ConstantInt *CI = dyn_cast(V)) {
+ isValidConstant = true;
+ C = CI->getRawValue();
+ }
+ else if (const ConstantFP *CFP = dyn_cast(V)) {
+ isValidConstant = true;
+ double fC = CFP->getValue();
+ C = (destType->isSigned()? (uint64_t) (int64_t) fC
+ : (uint64_t) fC);
+ }
+
+ // Now if a valid value was found, convert it to destType.
if (isValidConstant) {
- if (V->getType()->isSigned() || C < INT64_MAX) // safe to cast to signed
- return (int64_t) C;
- else
- isValidConstant = false;
+ unsigned opSize = target.getTargetData().getTypeSize(V->getType());
+ unsigned destSize = target.getTargetData().getTypeSize(destType);
+ uint64_t maskHi = (destSize < 8)? (1U << 8*destSize) - 1 : ~0;
+ assert(opSize <= 8 && destSize <= 8 && ">8-byte int type unexpected");
+
+ if (destType->isSigned()) {
+ if (opSize > destSize) // operand is larger than dest:
+ C = C & maskHi; // mask high bits
+
+ if (opSize > destSize ||
+ (opSize == destSize && ! V->getType()->isSigned()))
+ if (C & (1U << (8*destSize - 1)))
+ C = C | ~maskHi; // sign-extend from destSize to 64 bits
+ }
+ else {
+ if (opSize > destSize || (V->getType()->isSigned() && destSize < 8)) {
+ // operand is larger than dest,
+ // OR both are equal but smaller than the full register size
+ // AND operand is signed, so it may have extra sign bits:
+ // mask high bits
+ C = C & maskHi;
+ }
+ }
}
- return 0;
+
+ return C;
}
@@ -410,49 +460,25 @@
//
const Type* valType = val->getType();
- // Unfortunate special case: a ConstantPointerRef is just a
- // reference to GlobalValue.
- if (isa(val))
+ // A ConstantPointerRef is just a reference to GlobalValue.
+ while (isa(val))
val = cast(val)->getValue();
if (isa(val)) {
TmpInstruction* tmpReg =
new TmpInstruction(mcfi, PointerType::get(val->getType()), val);
CreateSETXLabel(target, val, tmpReg, dest, mvec);
- } else if (valType->isIntegral()) {
- bool isValidConstant;
- unsigned opSize = target.getTargetData().getTypeSize(val->getType());
- unsigned destSize = target.getTargetData().getTypeSize(dest->getType());
-
- if (! dest->getType()->isSigned()) {
- uint64_t C = GetConstantValueAsUnsignedInt(val, isValidConstant);
- assert(isValidConstant && "Unrecognized constant");
+ return;
+ }
- if (opSize > destSize || (val->getType()->isSigned() && destSize < 8)) {
- // operand is larger than dest,
- // OR both are equal but smaller than the full register size
- // AND operand is signed, so it may have extra sign bits:
- // mask high bits
- C = C & ((1U << 8*destSize) - 1);
- }
+ bool isValid;
+ uint64_t C = ConvertConstantToIntType(target, val, dest->getType(), isValid);
+ if (isValid) {
+ if (dest->getType()->isSigned())
CreateUIntSetInstruction(target, C, dest, mvec, mcfi);
- } else {
- int64_t C = GetConstantValueAsSignedInt(val, isValidConstant);
- assert(isValidConstant && "Unrecognized constant");
-
- if (opSize > destSize)
- // operand is larger than dest: mask high bits
- C = C & ((1U << 8*destSize) - 1);
+ else
+ CreateIntSetInstruction(target, (int64_t) C, dest, mvec, mcfi);
- if (opSize > destSize ||
- (opSize == destSize && !val->getType()->isSigned()))
- // sign-extend from destSize to 64 bits
- C = ((C & (1U << (8*destSize - 1)))
- ? C | ~((1U << 8*destSize) - 1)
- : C);
-
- CreateIntSetInstruction(target, C, dest, mvec, mcfi);
- }
} else {
// Make an instruction sequence to load the constant, viz:
// SETX , tmpReg, addrReg
@@ -465,10 +491,10 @@
// Create another TmpInstruction for the address register
TmpInstruction* addrReg =
new TmpInstruction(mcfi, PointerType::get(val->getType()), val);
-
+
// Put the address (a symbolic name) into a register
CreateSETXLabel(target, val, tmpReg, addrReg, mvec);
-
+
// Generate the load instruction
int64_t zeroOffset = 0; // to avoid ambiguity with (Value*) 0
unsigned Opcode = ChooseLoadInstruction(val->getType());
From vadve at cs.uiuc.edu Tue Jul 29 14:59:04 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 14:59:04 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/Sparc.cpp
Message-ID: <200307291958.OAA04701@psmith.cs.uiuc.edu>
Changes in directory llvm/lib/Target/Sparc:
Sparc.cpp updated: 1.69 -> 1.70
---
Log message:
Rename 'dump-asm' to 'dump-input' and really print it just before code-gen.
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/Sparc.cpp
diff -u llvm/lib/Target/Sparc/Sparc.cpp:1.69 llvm/lib/Target/Sparc/Sparc.cpp:1.70
--- llvm/lib/Target/Sparc/Sparc.cpp:1.69 Wed Jun 18 16:14:21 2003
+++ llvm/lib/Target/Sparc/Sparc.cpp Tue Jul 29 14:58:00 2003
@@ -52,8 +52,8 @@
cl::desc("Do not strip the LLVM bytecode included in the executable"));
static cl::opt
-DumpAsm("dump-asm", cl::desc("Print bytecode before native code generation"),
- cl::Hidden);
+DumpInput("dump-input",cl::desc("Print bytecode before native code generation"),
+ cl::Hidden);
//----------------------------------------------------------------------------
// allocateSparcTargetMachine - Allocate and return a subclass of TargetMachine
@@ -154,10 +154,6 @@
// Replace malloc and free instructions with library calls.
PM.add(createLowerAllocationsPass());
- // If LLVM dumping after transformations is requested, add it to the pipeline
- if (DumpAsm)
- PM.add(new PrintFunctionPass("Code after xformations: \n", &std::cerr));
-
// Strip all of the symbols from the bytecode so that it will be smaller...
if (!DisableStrip)
PM.add(createSymbolStrippingPass());
@@ -180,6 +176,10 @@
PM.add(createLICMPass());
PM.add(createGCSEPass());
}
+
+ // If LLVM dumping after transformations is requested, add it to the pipeline
+ if (DumpInput)
+ PM.add(new PrintFunctionPass("Input code to instr. selection: \n", &std::cerr));
PM.add(createInstructionSelectionPass(*this));
From vadve at cs.uiuc.edu Tue Jul 29 15:00:03 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 15:00:03 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrSelection.cpp
Message-ID: <200307291959.OAA04735@psmith.cs.uiuc.edu>
Changes in directory llvm/lib/Target/Sparc:
SparcInstrSelection.cpp updated: 1.108 -> 1.109
---
Log message:
Unify all constant evaluations that depend on register size
in ConvertConstantToIntType.
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/SparcInstrSelection.cpp
diff -u llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.108 llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.109
--- llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.108 Fri Jul 25 16:08:58 2003
+++ llvm/lib/Target/Sparc/SparcInstrSelection.cpp Tue Jul 29 14:59:23 2003
@@ -823,7 +823,8 @@
if (resultType->isInteger() || isa(resultType)) {
bool isValidConst;
- int64_t C = GetConstantValueAsSignedInt(constOp, isValidConst);
+ int64_t C = (int64_t) target.getInstrInfo().ConvertConstantToIntType(target,
+ constOp, constOp->getType(), isValidConst);
if (isValidConst) {
unsigned pow;
bool needNeg = false;
@@ -976,14 +977,15 @@
if (resultType->isInteger()) {
unsigned pow;
bool isValidConst;
- int64_t C = GetConstantValueAsSignedInt(constOp, isValidConst);
+ int64_t C = (int64_t) target.getInstrInfo().ConvertConstantToIntType(target,
+ constOp, constOp->getType(), isValidConst);
if (isValidConst) {
bool needNeg = false;
if (C < 0) {
needNeg = true;
C = -C;
}
-
+
if (C == 1) {
mvec.push_back(BuildMI(V9::ADDr, 3).addReg(LHS).addMReg(ZeroReg)
.addRegDef(destVal));
@@ -1085,7 +1087,9 @@
// compile time if the total size is a known constant.
if (isa(numElementsVal)) {
bool isValid;
- int64_t numElem = GetConstantValueAsSignedInt(numElementsVal, isValid);
+ int64_t numElem = (int64_t) target.getInstrInfo().
+ ConvertConstantToIntType(target, numElementsVal,
+ numElementsVal->getType(), isValid);
assert(isValid && "Unexpectedly large array dimension in alloca!");
int64_t total = numElem * tsize;
if (int extra= total % target.getFrameInfo().getStackFrameSizeAlignment())
@@ -1634,7 +1638,8 @@
if ((constVal->getType()->isInteger()
|| isa(constVal->getType()))
- && GetConstantValueAsSignedInt(constVal, isValidConst) == 0
+ && target.getInstrInfo().ConvertConstantToIntType(target,
+ constVal, constVal->getType(), isValidConst) == 0
&& isValidConst)
{
// That constant is a zero after all...
@@ -2240,7 +2245,8 @@
if ((constVal->getType()->isInteger()
|| isa(constVal->getType()))
- && GetConstantValueAsSignedInt(constVal, isValidConst) == 0
+ && target.getInstrInfo().ConvertConstantToIntType(target,
+ constVal, constVal->getType(), isValidConst) == 0
&& isValidConst)
{
// That constant is an integer zero after all...
From vadve at cs.uiuc.edu Tue Jul 29 15:02:01 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 15:02:01 2003
Subject: [llvm-commits] CVS: llvm/test/Libraries/libinstr/tracelib.c
Message-ID: <200307292001.PAA11595@tank.cs.uiuc.edu>
Changes in directory llvm/test/Libraries/libinstr:
tracelib.c updated: 1.8 -> 1.9
---
Log message:
Bug fix: after reallocating the hash table, we have to re-insert each value
instead of copying table entries!
---
Diffs of the changes:
Index: llvm/test/Libraries/libinstr/tracelib.c
diff -u llvm/test/Libraries/libinstr/tracelib.c:1.8 llvm/test/Libraries/libinstr/tracelib.c:1.9
--- llvm/test/Libraries/libinstr/tracelib.c:1.8 Mon Jul 21 14:23:31 2003
+++ llvm/test/Libraries/libinstr/tracelib.c Tue Jul 29 15:01:01 2003
@@ -1,26 +1,24 @@
-/*===-- tracelib.c - Runtime routines for tracing ---------------*- C++ -*-===*\
-//
-// Runtime routines for supporting tracing of execution for code generated by
-// LLVM.
-//
-//===----------------------------------------------------------------------===*/
+/*===-- tracelib.c - Runtime routines for tracing ---------------*- C++ -*-===*
+ *
+ * Runtime routines for supporting tracing of execution for code generated by
+ * LLVM.
+ *
+ *===----------------------------------------------------------------------===*/
#include "tracelib.h"
#include
#include
#include
#include
-#ifndef sun
-#include
-#endif
+#include "Support/DataTypes.h"
/*===---------------------------------------------------------------------=====
* HASH FUNCTIONS
*===---------------------------------------------------------------------===*/
/* use #defines until we have inlining */
-typedef uint32_t Index; /* type of index/size for hash table */
-typedef uint32_t Generic; /* type of values stored in table */
+typedef uintptr_t Index; /* type of keys, size for hash table */
+typedef uint32_t Generic; /* type of values stored in table */
/* Index IntegerHashFunc(const Generic value, const Index size) */
#define IntegerHashFunc(value, size) \
@@ -38,7 +36,6 @@
#define PointerRehashFunc(value, size) \
IntegerRehashFunc((Index) value, size)
-
/*===---------------------------------------------------------------------=====
* POINTER-TO-GENERIC HASH TABLE.
* These should be moved to a separate location: HashTable.[ch]
@@ -71,6 +68,10 @@
extern void Delete(PtrValueHashTable* ptrTable, void* ptr);
+/* Returns NULL if the item is not found. */
+/* void* LookupPtr(PtrValueHashTable* ptrTable, void* ptr) */
+#define LookupPtr(ptrTable, ptr) \
+ LookupOrInsertPtr(ptrTable, ptr, FIND)
void
InitializeTable(PtrValueHashTable* ptrTable, Index newSize)
@@ -98,11 +99,9 @@
return;
#ifndef NDEBUG
- printf("\n***\n*** WARNING: REALLOCATING SPACE FOR POINTER HASH TABLE.\n");
- printf("*** oldSize = %d, oldCapacity = %d\n***\n\n",
- ptrTable->size, ptrTable->capacity);
- printf("*** NEW SEQUENCE NUMBER FOR A POINTER WILL PROBABLY NOT MATCH ");
- printf(" THE OLD ONE!\n***\n\n");
+ printf("\n***\n*** REALLOCATING SPACE FOR POINTER HASH TABLE.\n");
+ printf("*** oldSize = %ld, oldCapacity = %ld\n***\n\n",
+ (long) ptrTable->size, (long) ptrTable->capacity);
#endif
unsigned int i;
@@ -113,20 +112,18 @@
/* allocate the new storage and flags and re-insert the old entries */
InitializeTable(ptrTable, newSize);
- memcpy(ptrTable->table, oldTable,
- oldCapacity * sizeof(PtrValueHashEntry));
- memcpy(ptrTable->fullEmptyFlags, oldFlags,
- oldCapacity * sizeof(FULLEMPTY));
- ptrTable->size = oldSize;
+ for (i=0; i < oldCapacity; ++i)
+ if (oldFlags[i] == FULL)
+ Insert(ptrTable, oldTable[i].key, oldTable[i].value);
+
+ assert(ptrTable->size == oldSize && "Incorrect number of entries copied?");
#ifndef NDEBUG
- for (i=0; i < oldCapacity; ++i) {
- assert(ptrTable->fullEmptyFlags[i] == oldFlags[i]);
- assert(ptrTable->table[i].key == oldTable[i].key);
- assert(ptrTable->table[i].value == oldTable[i].value);
- }
+ for (i=0; i < oldCapacity; ++i)
+ if (! oldFlags[i])
+ assert(LookupPtr(ptrTable, oldTable[i].key) == oldTable[i].value);
#endif
-
+
free(oldTable);
free(oldFlags);
}
@@ -215,11 +212,6 @@
InsertAtIndex(ptrTable, ptr, (Generic) NULL, index);
return (Generic) NULL;
}
-
-/* Returns NULL if the item is not found. */
-/* void* LookupPtr(PtrValueHashTable* ptrTable, void* ptr) */
-#define LookupPtr(ptrTable, ptr) \
- LookupOrInsertPtr(ptrTable, ptr, FIND)
void
Insert(PtrValueHashTable* ptrTable, void* ptr, Generic value)
From vadve at cs.uiuc.edu Tue Jul 29 15:26:01 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 15:26:01 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/UnitTests/2003-07-08-BitOpsTest.c
Message-ID: <200307292025.PAA04837@psmith.cs.uiuc.edu>
Changes in directory llvm/test/Programs/SingleSource/UnitTests:
2003-07-08-BitOpsTest.c added (r1.1)
---
Log message:
Bit operations.
---
Diffs of the changes:
Index: llvm/test/Programs/SingleSource/UnitTests/2003-07-08-BitOpsTest.c
diff -c /dev/null llvm/test/Programs/SingleSource/UnitTests/2003-07-08-BitOpsTest.c:1.1
*** /dev/null Tue Jul 29 15:25:06 2003
--- llvm/test/Programs/SingleSource/UnitTests/2003-07-08-BitOpsTest.c Tue Jul 29 15:24:56 2003
***************
*** 0 ****
--- 1,15 ----
+ #include
+
+ void test(int A, int B, int C, int D) {
+ int bxor = A ^ B ^ C ^ D;
+ int bor = A | B | C | D;
+ int band = A & B & C & D;
+ int bandnot = (A & ~B) ^ (C & ~D);
+ int bornot = (A | ~B) ^ (C | ~D);
+
+ printf("%d %d %d %d %d\n", bxor, bor, band, bandnot, bornot);
+ }
+
+ void main() {
+ test(7, 8, -5, 5);
+ }
From vadve at cs.uiuc.edu Tue Jul 29 15:31:02 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Tue Jul 29 15:31:02 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetInstrInfo.h
Message-ID: <200307292030.PAA04913@psmith.cs.uiuc.edu>
Changes in directory llvm/include/llvm/Target:
TargetInstrInfo.h updated: 1.48 -> 1.49
---
Log message:
Unify all constant evaluations that depend on register size
in TargetInstrInfo::ConvertConstantToIntType.
---
Diffs of the changes:
Index: llvm/include/llvm/Target/TargetInstrInfo.h
diff -u llvm/include/llvm/Target/TargetInstrInfo.h:1.48 llvm/include/llvm/Target/TargetInstrInfo.h:1.49
--- llvm/include/llvm/Target/TargetInstrInfo.h:1.48 Fri Jul 25 12:58:41 2003
+++ llvm/include/llvm/Target/TargetInstrInfo.h Tue Jul 29 15:30:20 2003
@@ -14,6 +14,7 @@
class MachineInstr;
class TargetMachine;
class Value;
+class Type;
class Instruction;
class Constant;
class Function;
@@ -299,6 +300,21 @@
// Create* methods below should be moved to a machine code generation class
//
virtual MachineOpCode getNOPOpCode() const { abort(); }
+
+ // Get the value of an integral constant in the form that must
+ // be put into the machine register. The specified constant is interpreted
+ // as (i.e., converted if necessary to) the specified destination type. The
+ // result is always returned as an uint64_t, since the representation of
+ // int64_t and uint64_t are identical. The argument can be any known const.
+ //
+ // isValidConstant is set to true if a valid constant was found.
+ //
+ virtual uint64_t ConvertConstantToIntType(const TargetMachine &target,
+ const Value *V,
+ const Type *destType,
+ bool &isValidConstant) const {
+ abort();
+ }
// Create an instruction sequence to put the constant `val' into
// the virtual register `dest'. `val' may be a Constant or a
From brukman at cs.uiuc.edu Tue Jul 29 15:54:03 2003
From: brukman at cs.uiuc.edu (Misha Brukman)
Date: Tue Jul 29 15:54:03 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcV9CodeEmitter.h
Message-ID: <200307292053.PAA17249@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/Sparc:
SparcV9CodeEmitter.h updated: 1.12 -> 1.13
---
Log message:
Make emitFarCall() public, and add a few comments to functions.
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/SparcV9CodeEmitter.h
diff -u llvm/lib/Target/Sparc/SparcV9CodeEmitter.h:1.12 llvm/lib/Target/Sparc/SparcV9CodeEmitter.h:1.13
--- llvm/lib/Target/Sparc/SparcV9CodeEmitter.h:1.12 Sat Jul 26 18:04:00 2003
+++ llvm/lib/Target/Sparc/SparcV9CodeEmitter.h Tue Jul 29 15:52:56 2003
@@ -34,21 +34,45 @@
SparcV9CodeEmitter(TargetMachine &T, MachineCodeEmitter &M);
~SparcV9CodeEmitter();
+ /// runOnMachineFunction - emits the given machine function to memory.
+ ///
bool runOnMachineFunction(MachineFunction &F);
+
+ /// emitWord - writes out the given 32-bit value to memory at the current PC.
+ ///
void emitWord(unsigned Val);
- /// Function generated by the CodeEmitterGenerator using TableGen
+ /// getBinaryCodeForInstr - This function, generated by the
+ /// CodeEmitterGenerator using TableGen, produces the binary encoding for
+ /// machine instructions.
///
unsigned getBinaryCodeForInstr(MachineInstr &MI);
+ /// emitFarCall - produces a code sequence to make a call to a destination
+ /// that does not fit in the 30 bits that a call instruction allows.
+ ///
+ void emitFarCall(uint64_t Addr);
+
private:
+ /// getMachineOpValue -
+ ///
int64_t getMachineOpValue(MachineInstr &MI, MachineOperand &MO);
- inline unsigned getValueBit(int64_t Val, unsigned bit);
+
+ /// emitBasicBlock -
+ ///
void emitBasicBlock(MachineBasicBlock &MBB);
+
+ /// getValueBit -
+ ///
+ unsigned getValueBit(int64_t Val, unsigned bit);
+
+ /// getGlobalAddress -
+ ///
void* getGlobalAddress(GlobalValue *V, MachineInstr &MI,
bool isPCRelative);
+ /// emitFarCall -
+ ///
unsigned getRealRegNum(unsigned fakeReg, MachineInstr &MI);
- inline void emitFarCall(uint64_t Addr);
};
From brukman at cs.uiuc.edu Tue Jul 29 16:22:01 2003
From: brukman at cs.uiuc.edu (Misha Brukman)
Date: Tue Jul 29 16:22:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcV9.td
Message-ID: <200307292121.QAA00660@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/Sparc:
SparcV9.td updated: 1.24 -> 1.25
---
Log message:
* Cleaned up and corrected comments wrt instruction formats
* Enabled STXFSR instructions
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/SparcV9.td
diff -u llvm/lib/Target/Sparc/SparcV9.td:1.24 llvm/lib/Target/Sparc/SparcV9.td:1.25
--- llvm/lib/Target/Sparc/SparcV9.td:1.24 Mon Jul 7 17:18:42 2003
+++ llvm/lib/Target/Sparc/SparcV9.td Tue Jul 29 16:21:20 2003
@@ -98,7 +98,7 @@
}
// Section A.5: Branch on FP condition codes with prediction - p143
-// Not used in the Sparc backend
+// Not used in the Sparc backend (directly)
#if 0
set op2 = 0b101 in {
def FBPA : F2_3<0b1000, "fba">; // Branch always
@@ -121,7 +121,7 @@
#endif
// Section A.6: Branch on Integer condition codes (Bicc) - p146
-#if 0 /* instead of using deprecated version, use the predicted version below */
+#if 0
set isDeprecated = 1 in {
set op2 = 0b010 in {
def BA : F2_2<0b1000, "ba">; // Branch always
@@ -146,7 +146,7 @@
// Using the format of A.7 instructions...
set op2 = 0b001 in {
- set cc = 0 in { // BA and BN don't read condition codes
+ set cc = 0 in { // BA and BN don't read condition codes
def BA : F2_3<0b1000, "ba">; // Branch always
def BN : F2_3<0b0000, "bn">; // Branch never
}
@@ -226,13 +226,13 @@
}
#endif
-// Section A.12: Floating-Point Add and Subtract - p182
-def FADDS : F3_16<2, 0b110100, 0x41, "fadds">; // fadds f, f, f
-def FADDD : F3_16<2, 0b110100, 0x42, "faddd">; // faddd f, f, f
-def FADDQ : F3_16<2, 0b110100, 0x43, "faddq">; // faddq f, f, f
-def FSUBS : F3_16<2, 0b110100, 0x45, "fsubs">; // fsubs f, f, f
-def FSUBD : F3_16<2, 0b110100, 0x46, "fsubd">; // fsubd f, f, f
-def FSUBQ : F3_16<2, 0b110100, 0x47, "fsubq">; // fsubq f, f, f
+// Section A.12: Floating-Point Add and Subtract - p156
+def FADDS : F3_16<2, 0b110100, 0x41, "fadds">; // fadds frs1, frs2, frd
+def FADDD : F3_16<2, 0b110100, 0x42, "faddd">; // faddd frs1, frs2, frd
+def FADDQ : F3_16<2, 0b110100, 0x43, "faddq">; // faddq frs1, frs2, frd
+def FSUBS : F3_16<2, 0b110100, 0x45, "fsubs">; // fsubs frs1, frs2, frd
+def FSUBD : F3_16<2, 0b110100, 0x46, "fsubd">; // fsubd frs1, frs2, frd
+def FSUBQ : F3_16<2, 0b110100, 0x47, "fsubq">; // fsubq frs1, frs2, frd
// Section A.13: Floating-point compare - p159
def FCMPS : F3_15<2, 0b110101, 0b001010001, "fcmps">; // fcmps %fcc, r1, r2
@@ -590,7 +590,7 @@
def MOVFOr : F4_3<2, 0b101100, 0b1111, "movfo">; // movfo i/xcc, rs2, rd
def MOVFOi : F4_4<2, 0b101100, 0b1111, "movfo">; // movfo i/xcc, imm, rd
-// Section A.36: Move Integer Register on Register Condition (MOVR)
+// Section A.36: Move Integer Register on Register Condition (MOVR) - p198
def MOVRZr : F3_5<2, 0b101111, 0b001, "movrz">; // movrz rs1, rs2, rd
def MOVRZi : F3_6<2, 0b101111, 0b001, "movrz">; // movrz rs1, imm, rd
def MOVRLEZr : F3_5<2, 0b101111, 0b010, "movrlez">; // movrlez rs1, rs2, rd
@@ -737,9 +737,9 @@
def STFSRr : F3_1<3, 0b100101, "st">; // st %fsr, [r+r]
def STFSRi : F3_2<3, 0b100101, "st">; // st %fsr, [r+i]
}
+#endif
def STXFSRr : F3_1<3, 0b100101, "stx">; // stx %fsr, [r+r]
def STXFSRi : F3_2<3, 0b100101, "stx">; // stx %fsr, [r+i]
-#endif
// Section A.53: Store Floating-Point into Alternate Space - p227
// Not currently used in the Sparc backend
@@ -748,12 +748,12 @@
// Store instructions all want their rd register first
def STBr : F3_1rd<3, 0b000101, "stb">; // stb r, [r+r]
def STBi : F3_2rd<3, 0b000101, "stb">; // stb r, [r+i]
-def STHr : F3_1rd<3, 0b000110, "sth">; // stb r, [r+r]
-def STHi : F3_2rd<3, 0b000110, "sth">; // stb r, [r+i]
-def STWr : F3_1rd<3, 0b000100, "stw">; // stb r, [r+r]
-def STWi : F3_2rd<3, 0b000100, "stw">; // stb r, [r+i]
-def STXr : F3_1rd<3, 0b001110, "stx">; // stb r, [r+r]
-def STXi : F3_2rd<3, 0b001110, "stx">; // stb r, [r+i]
+def STHr : F3_1rd<3, 0b000110, "sth">; // sth r, [r+r]
+def STHi : F3_2rd<3, 0b000110, "sth">; // sth r, [r+i]
+def STWr : F3_1rd<3, 0b000100, "stw">; // stw r, [r+r]
+def STWi : F3_2rd<3, 0b000100, "stw">; // stw r, [r+i]
+def STXr : F3_1rd<3, 0b001110, "stx">; // stx r, [r+r]
+def STXi : F3_2rd<3, 0b001110, "stx">; // stx r, [r+i]
// Section A.55: Store Integer into Alternate Space - p231
// Not currently used in the Sparc backend
From gaeke at cs.uiuc.edu Tue Jul 29 17:00:02 2003
From: gaeke at cs.uiuc.edu (Brian Gaeke)
Date: Tue Jul 29 17:00:02 2003
Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Reoptimizer.h
Message-ID: <200307292159.QAA21861@neo.cs.uiuc.edu>
Changes in directory llvm/lib/Reoptimizer:
Reoptimizer.h (r1.2) removed
---
Log message:
This file does not appear to be used anywhere.
---
Diffs of the changes:
From criswell at cs.uiuc.edu Tue Jul 29 17:41:01 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Tue Jul 29 17:41:01 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT2000/254.gap/Makefile
Message-ID: <200307292240.RAA00695@morpheus.cs.uiuc.edu>
Changes in directory llvm/test/Programs/External/SPEC/CINT2000/254.gap:
Makefile updated: 1.2 -> 1.3
---
Log message:
Added the SPEC_CPU2000_LP64 macro definition to get correct compilation on
Ultrasparc.
---
Diffs of the changes:
Index: llvm/test/Programs/External/SPEC/CINT2000/254.gap/Makefile
diff -u llvm/test/Programs/External/SPEC/CINT2000/254.gap/Makefile:1.2 llvm/test/Programs/External/SPEC/CINT2000/254.gap/Makefile:1.3
--- llvm/test/Programs/External/SPEC/CINT2000/254.gap/Makefile:1.2 Sat May 31 18:17:27 2003
+++ llvm/test/Programs/External/SPEC/CINT2000/254.gap/Makefile Tue Jul 29 17:40:03 2003
@@ -4,3 +4,6 @@
STDIN_FILENAME = $(RUN_TYPE).in
CPPFLAGS = -DSYS_IS_USG -DSYS_HAS_CALLOC_PROTO -DSYS_HAS_IOCTL_PROTO -DSYS_HAS_TIME_PROTO
include ../../Makefile.spec
+ifeq ($(ARCH),Sparc)
+CPPFLAGS+= -DSPEC_CPU2000_LP64
+endif
From lattner at cs.uiuc.edu Tue Jul 29 18:01:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Jul 29 18:01:01 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/CodeEmitterGen.cpp CodeEmitterGen.h TableGen.cpp
Message-ID: <200307292300.SAA16043@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
CodeEmitterGen.cpp updated: 1.13 -> 1.14
CodeEmitterGen.h updated: 1.2 -> 1.3
TableGen.cpp updated: 1.7 -> 1.8
---
Log message:
Don't crash if there is no Inst class in the tablegen file!
---
Diffs of the changes:
Index: llvm/utils/TableGen/CodeEmitterGen.cpp
diff -u llvm/utils/TableGen/CodeEmitterGen.cpp:1.13 llvm/utils/TableGen/CodeEmitterGen.cpp:1.14
--- llvm/utils/TableGen/CodeEmitterGen.cpp:1.13 Fri Jul 18 13:03:45 2003
+++ llvm/utils/TableGen/CodeEmitterGen.cpp Tue Jul 29 18:00:08 2003
@@ -2,7 +2,7 @@
#include "Record.h"
#include "CodeEmitterGen.h"
-void CodeEmitterGen::createEmitter(std::ostream &o) {
+int CodeEmitterGen::createEmitter(std::ostream &o) {
std::vector Insts;
const std::map &Defs = Records.getDefs();
@@ -31,8 +31,12 @@
<< " DEBUG(std::cerr << \"Emitting " << R->getName() << "\\n\");\n";
const RecordVal *InstVal = R->getValue("Inst");
- Init *InitVal = InstVal->getValue();
+ if (!InstVal) {
+ std::cerr << "No 'Inst' record found in target description file!\n";
+ return 1;
+ }
+ Init *InitVal = InstVal->getValue();
assert(dynamic_cast(InitVal) &&
"Can only handle undefined bits<> types!");
BitsInit *BI = (BitsInit*)InitVal;
@@ -225,4 +229,5 @@
<< " }\n"
<< " return Value;\n"
<< "}\n";
+ return 0;
}
Index: llvm/utils/TableGen/CodeEmitterGen.h
diff -u llvm/utils/TableGen/CodeEmitterGen.h:1.2 llvm/utils/TableGen/CodeEmitterGen.h:1.3
--- llvm/utils/TableGen/CodeEmitterGen.h:1.2 Fri Jun 6 18:06:20 2003
+++ llvm/utils/TableGen/CodeEmitterGen.h Tue Jul 29 18:00:08 2003
@@ -15,7 +15,7 @@
public:
CodeEmitterGen(RecordKeeper &R) : Records(R) {}
- void createEmitter(std::ostream &o);
+ int createEmitter(std::ostream &o);
void emitMachineOpEmitter(std::ostream &o, const std::string &Namespace);
void emitGetValueBit(std::ostream &o, const std::string &Namespace);
};
Index: llvm/utils/TableGen/TableGen.cpp
diff -u llvm/utils/TableGen/TableGen.cpp:1.7 llvm/utils/TableGen/TableGen.cpp:1.8
--- llvm/utils/TableGen/TableGen.cpp:1.7 Tue Jun 3 00:07:28 2003
+++ llvm/utils/TableGen/TableGen.cpp Tue Jul 29 18:00:08 2003
@@ -394,10 +394,12 @@
RemoveFileOnSignal(OutputFilename);
}
+ int ErrorCode = 0;
+
switch (Action) {
case Parse: ParseMachineCode(); break;
case GenEmitter:
- CodeEmitterGen(Records).createEmitter(*Out);
+ ErrorCode = CodeEmitterGen(Records).createEmitter(*Out);
break;
case PrintRecords:
*Out << Records; // No argument, dump all contents
@@ -421,5 +423,5 @@
}
if (Out != &std::cout) delete Out;
- return 0;
+ return ErrorCode;
}
From lattner at cs.uiuc.edu Tue Jul 29 18:04:02 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Jul 29 18:04:02 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Target.td
Message-ID: <200307292303.SAA16246@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Target:
Target.td updated: 1.2 -> 1.3
---
Log message:
Add namespace specifier, add flags used by the X86 BE
---
Diffs of the changes:
Index: llvm/lib/Target/Target.td
diff -u llvm/lib/Target/Target.td:1.2 llvm/lib/Target/Target.td:1.3
--- llvm/lib/Target/Target.td:1.2 Sun Jul 27 23:24:59 2003
+++ llvm/lib/Target/Target.td Tue Jul 29 18:02:49 2003
@@ -8,8 +8,8 @@
// Value types - These values correspond to the register types defined in the
-// MRegsterInfo.h file.
-class ValueType {}
+// ValueTypes.h file.
+class ValueType { string Namespace = "MVT"; }
def i1 : ValueType; // One bit boolean value
def i8 : ValueType; // 8-bit integer value
def i16 : ValueType; // 16-bit integer value
@@ -35,7 +35,9 @@
// These bits capture information about the high-level semantics of the
// instruction.
- bit isReturn = 0; // Is this instruction a return instruction?
- bit isBranch = 0; // Is this instruction a branch instruction?
- bit isCall = 0; // Is this instruction a call instruction?
+ bit isReturn = 0; // Is this instruction a return instruction?
+ bit isBranch = 0; // Is this instruction a branch instruction?
+ bit isCall = 0; // Is this instruction a call instruction?
+ bit isTwoAddress = 0; // Is this a two address instruction?
+ bit isTerminator = 0; // Is this part of the terminator for a basic block?
}
From lattner at cs.uiuc.edu Tue Jul 29 18:05:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Jul 29 18:05:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/Makefile
Message-ID: <200307292304.SAA16479@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Target/Sparc:
Makefile updated: 1.24 -> 1.25
---
Log message:
Do not use 'cpp' directly
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/Makefile
diff -u llvm/lib/Target/Sparc/Makefile:1.24 llvm/lib/Target/Sparc/Makefile:1.25
--- llvm/lib/Target/Sparc/Makefile:1.24 Mon Jun 30 16:58:49 2003
+++ llvm/lib/Target/Sparc/Makefile Tue Jul 29 18:04:41 2003
@@ -45,7 +45,7 @@
SparcV9CodeEmitter.inc: SparcV9.td SparcV9_F2.td SparcV9_F3.td SparcV9_F4.td SparcV9_Reg.td $(TBLGEN)
@${ECHO} "TableGen-erating $@"
- cpp -P SparcV9.td | $(TBLGEN) -gen-emitter -o $@
+ $(CC) -E -xc -P SparcV9.td | $(TBLGEN) -gen-emitter -o $@
clean::
${RM} -f SparcV9CodeEmitter.inc
From lattner at cs.uiuc.edu Tue Jul 29 18:08:02 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Jul 29 18:08:02 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Target.td
Message-ID: <200307292307.SAA16506@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Target:
Target.td updated: 1.3 -> 1.4
---
Log message:
No this file is not actually Sparc.td :)
---
Diffs of the changes:
Index: llvm/lib/Target/Target.td
diff -u llvm/lib/Target/Target.td:1.3 llvm/lib/Target/Target.td:1.4
--- llvm/lib/Target/Target.td:1.3 Tue Jul 29 18:02:49 2003
+++ llvm/lib/Target/Target.td Tue Jul 29 18:07:13 2003
@@ -1,11 +1,9 @@
-//===- Sparc.td - Target Description for Sparc V9 Target --------*- C++ -*-===//
-// vim:ft=cpp
+//===- Target.td - Target Independent TableGen interface --------*- C++ -*-===//
+//
+// This file defines the target-independent interfaces which should be
+// implemented by each target which is using a TableGen based code generator.
+//
//===----------------------------------------------------------------------===//
-
-//===----------------------------------------------------------------------===//
-// Target-Independent interface
-//===----------------------------------------------------------------------===//
-
// Value types - These values correspond to the register types defined in the
// ValueTypes.h file.
From lattner at cs.uiuc.edu Tue Jul 29 23:06:00 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Jul 29 23:06:00 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/Record.cpp Record.h
Message-ID: <200307300405.XAA25744@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
Record.cpp updated: 1.9 -> 1.10
Record.h updated: 1.11 -> 1.12
---
Log message:
Implement resolution of variables to the value of the variable once it gets a value
---
Diffs of the changes:
Index: llvm/utils/TableGen/Record.cpp
diff -u llvm/utils/TableGen/Record.cpp:1.9 llvm/utils/TableGen/Record.cpp:1.10
--- llvm/utils/TableGen/Record.cpp:1.9 Sun Jul 27 22:39:57 2003
+++ llvm/utils/TableGen/Record.cpp Tue Jul 29 23:05:07 2003
@@ -215,6 +215,9 @@
return false;
}
+// resolveReferences - If there are any field references that refer to fields
+// that have been filled in, we can propagate the values now.
+//
Init *BitsInit::resolveReferences(Record &R) {
bool Changed = false;
BitsInit *New = new BitsInit(getNumBits());
@@ -309,7 +312,18 @@
return 0;
}
-
+/// resolveReferences - This method is used by classes that refer to other
+/// variables which may not be defined at the time they expression is formed.
+/// If a value is set for the variable later, this method will be called on
+/// users of the value to allow the value to propagate out.
+///
+Init *VarInit::resolveReferences(Record &R) {
+ if (RecordVal *Val = R.getValue(VarName))
+ if (!dynamic_cast(Val->getValue()))
+ return Val->getValue();
+ return this;
+}
+
Init *VarBitInit::resolveReferences(Record &R) {
Init *I = getVariable()->resolveBitReference(R, getBitNum());
Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.11 llvm/utils/TableGen/Record.h:1.12
--- llvm/utils/TableGen/Record.h:1.11 Sun Jul 27 22:39:57 2003
+++ llvm/utils/TableGen/Record.h Tue Jul 29 23:05:07 2003
@@ -365,6 +365,13 @@
virtual RecTy *getFieldType(const std::string &FieldName) const;
virtual Init *getFieldInit(Record &R, const std::string &FieldName) const;
+
+ /// resolveReferences - This method is used by classes that refer to other
+ /// variables which may not be defined at the time they expression is formed.
+ /// If a value is set for the variable later, this method will be called on
+ /// users of the value to allow the value to propagate out.
+ ///
+ virtual Init *resolveReferences(Record &R);
virtual void print(std::ostream &OS) const { OS << VarName; }
};
From lattner at cs.uiuc.edu Tue Jul 29 23:18:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Jul 29 23:18:01 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/Record.h Record.cpp
Message-ID: <200307300417.XAA26474@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
Record.h updated: 1.12 -> 1.13
Record.cpp updated: 1.10 -> 1.11
---
Log message:
Allow passing lists through variables
---
Diffs of the changes:
Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.12 llvm/utils/TableGen/Record.h:1.13
--- llvm/utils/TableGen/Record.h:1.12 Tue Jul 29 23:05:07 2003
+++ llvm/utils/TableGen/Record.h Tue Jul 29 23:16:52 2003
@@ -108,7 +108,7 @@
struct StringRecTy : public RecTy {
Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
Init *convertValue(StringInit *SI) { return (Init*)SI; }
- Init *convertValue(TypedInit *VI);
+ Init *convertValue(TypedInit *TI);
void print(std::ostream &OS) const { OS << "string"; }
};
@@ -119,8 +119,14 @@
Record *Class;
public:
ListRecTy(Record *C) : Class(C) {}
+
+ /// getElementClass - Return the class that the list contains.
+ ///
+ Record *getElementClass() const { return Class; }
+
Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
Init *convertValue(ListInit *LI);
+ Init *convertValue(TypedInit *TI);
void print(std::ostream &OS) const;
};
Index: llvm/utils/TableGen/Record.cpp
diff -u llvm/utils/TableGen/Record.cpp:1.10 llvm/utils/TableGen/Record.cpp:1.11
--- llvm/utils/TableGen/Record.cpp:1.10 Tue Jul 29 23:05:07 2003
+++ llvm/utils/TableGen/Record.cpp Tue Jul 29 23:16:52 2003
@@ -116,6 +116,14 @@
return LI;
}
+Init *ListRecTy::convertValue(TypedInit *TI) {
+ // Ensure that TI is compatible with our class.
+ if (ListRecTy *LRT = dynamic_cast(TI->getType()))
+ if (LRT->getElementClass() == getElementClass())
+ return TI;
+ return 0;
+}
+
void RecordRecTy::print(std::ostream &OS) const {
OS << Rec->getName();
}
@@ -127,12 +135,12 @@
return DI;
}
-Init *RecordRecTy::convertValue(TypedInit *VI) {
- // Ensure that VI is compatible with Rec.
- if (RecordRecTy *RRT = dynamic_cast(VI->getType()))
+Init *RecordRecTy::convertValue(TypedInit *TI) {
+ // Ensure that TI is compatible with Rec.
+ if (RecordRecTy *RRT = dynamic_cast(TI->getType()))
if (RRT->getRecord()->isSubClassOf(getRecord()) ||
RRT->getRecord() == getRecord())
- return VI;
+ return TI;
return 0;
}
From lattner at cs.uiuc.edu Tue Jul 29 23:27:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Jul 29 23:27:01 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileParser.y
Message-ID: <200307300426.XAA28167@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
FileParser.y updated: 1.6 -> 1.7
---
Log message:
Allow specification of anonymous definitions
---
Diffs of the changes:
Index: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.6 llvm/utils/TableGen/FileParser.y:1.7
--- llvm/utils/TableGen/FileParser.y:1.6 Sun Jul 27 22:49:40 2003
+++ llvm/utils/TableGen/FileParser.y Tue Jul 29 23:26:44 2003
@@ -6,10 +6,10 @@
%{
#include "Record.h"
+#include "Support/StringExtras.h"
#include
#include
-#include
-#include
+#include
#define YYERROR_VERBOSE 1
int yyerror(const char *ErrorMsg);
@@ -181,7 +181,7 @@
%type Value OptValue
%type ValueList ValueListNE
%type BitList OptBitList RBitList
-%type Declaration
+%type Declaration OptID
%start File
%%
@@ -398,7 +398,12 @@
TemplateArgList : '<' DeclListNE '>' {};
OptTemplateArgList : /*empty*/ | TemplateArgList;
-ObjectBody : ID {
+OptID : ID { $$ = $1; } | /*empty*/ { $$ = new std::string(); };
+
+ObjectBody : OptID {
+ static unsigned AnonCounter = 0;
+ if ($1->empty())
+ *$1 = "anonymous."+utostr(AnonCounter++);
CurRec = new Record(*$1);
delete $1;
} OptTemplateArgList ClassList {
From lattner at cs.uiuc.edu Tue Jul 29 23:32:00 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Jul 29 23:32:00 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileParser.y
Message-ID: <200307300431.XAA28632@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
FileParser.y updated: 1.7 -> 1.8
---
Log message:
Implement TODO: disallow 'def's with template arguments.
---
Diffs of the changes:
Index: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.7 llvm/utils/TableGen/FileParser.y:1.8
--- llvm/utils/TableGen/FileParser.y:1.7 Tue Jul 29 23:26:44 2003
+++ llvm/utils/TableGen/FileParser.y Tue Jul 29 23:31:17 2003
@@ -432,7 +432,12 @@
};
DefInst : DEF ObjectBody {
- // TODO: If ObjectBody has template arguments, it's an error.
+ if (!$2->getTemplateArgs().empty()) {
+ err() << "Def '" << $2->getName()
+ << "' is not permitted to have template arguments!\n";
+ abort();
+ }
+ // If ObjectBody has template arguments, it's an error.
if (Records.getDef($2->getName())) {
err() << "Def '" << $2->getName() << "' already defined!\n";
abort();
From lattner at cs.uiuc.edu Tue Jul 29 23:57:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Jul 29 23:57:01 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileParser.y Record.h
Message-ID: <200307300456.XAA31081@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
FileParser.y updated: 1.8 -> 1.9
Record.h updated: 1.13 -> 1.14
---
Log message:
Don't pollute the namespace with template arguments after they have been resolved
---
Diffs of the changes:
Index: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.8 llvm/utils/TableGen/FileParser.y:1.9
--- llvm/utils/TableGen/FileParser.y:1.8 Tue Jul 29 23:31:17 2003
+++ llvm/utils/TableGen/FileParser.y Tue Jul 29 23:56:04 2003
@@ -409,9 +409,9 @@
} OptTemplateArgList ClassList {
for (unsigned i = 0, e = $4->size(); i != e; ++i) {
addSubClass((*$4)[i].first, *(*$4)[i].second);
- delete (*$4)[i].second; // Delete the template list
- }
- delete $4;
+ // Delete the template arg values for the class
+ delete (*$4)[i].second;
+ }
// Process any variables on the set stack...
for (unsigned i = 0, e = SetStack.size(); i != e; ++i)
@@ -419,6 +419,17 @@
SetStack[i].second);
} Body {
CurRec->resolveReferences();
+
+ // Now that all of the references have been resolved, we can delete template
+ // arguments for superclasses, so they don't pollute our record, and so that
+ // their names won't conflict with later uses of the name...
+ for (unsigned i = 0, e = $4->size(); i != e; ++i) {
+ Record *SuperClass = (*$4)[i].first;
+ for (unsigned i = 0, e = SuperClass->getTemplateArgs().size(); i != e; ++i)
+ CurRec->removeValue(SuperClass->getTemplateArgs()[i]);
+ }
+ delete $4; // Delete the class list...
+
$$ = CurRec;
CurRec = 0;
};
Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.13 llvm/utils/TableGen/Record.h:1.14
--- llvm/utils/TableGen/Record.h:1.13 Tue Jul 29 23:16:52 2003
+++ llvm/utils/TableGen/Record.h Tue Jul 29 23:56:05 2003
@@ -536,6 +536,16 @@
Values.push_back(RV);
}
+ void removeValue(const std::string &Name) {
+ assert(getValue(Name) && "Cannot remove an entry that does not exist!");
+ for (unsigned i = 0, e = Values.size(); i != e; ++i)
+ if (Values[i].getName() == Name) {
+ Values.erase(Values.begin()+i);
+ return;
+ }
+ assert(0 && "Name does not exist in record!");
+ }
+
bool isSubClassOf(Record *R) const {
for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i)
if (SuperClasses[i] == R)
From lattner at cs.uiuc.edu Wed Jul 30 00:18:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 00:18:01 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileParser.y
Message-ID: <200307300517.AAA31820@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
FileParser.y updated: 1.9 -> 1.10
---
Log message:
Fix coredump for when an ID is used illegally outside a record
---
Diffs of the changes:
Index: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.9 llvm/utils/TableGen/FileParser.y:1.10
--- llvm/utils/TableGen/FileParser.y:1.9 Tue Jul 29 23:56:04 2003
+++ llvm/utils/TableGen/FileParser.y Wed Jul 30 00:17:35 2003
@@ -245,6 +245,10 @@
$$ = Init;
delete $2;
} | ID {
+ if (CurRec == 0) {
+ err() << "Def/Class name '" << *$1 << "' not allowed here!\n";
+ abort();
+ }
if (const RecordVal *RV = CurRec->getValue(*$1)) {
$$ = new VarInit(*$1, RV->getType());
} else if (Record *D = Records.getDef(*$1)) {
From lattner at cs.uiuc.edu Wed Jul 30 00:30:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 00:30:01 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/Target/MRegisterInfo.h
Message-ID: <200307300529.AAA32248@apoc.cs.uiuc.edu>
Changes in directory llvm/include/llvm/Target:
MRegisterInfo.h updated: 1.19 -> 1.20
---
Log message:
Code generation passes don't need access to raw LLVM types, this method is unnecessary.
---
Diffs of the changes:
Index: llvm/include/llvm/Target/MRegisterInfo.h
diff -u llvm/include/llvm/Target/MRegisterInfo.h:1.19 llvm/include/llvm/Target/MRegisterInfo.h:1.20
--- llvm/include/llvm/Target/MRegisterInfo.h:1.19 Tue Jul 29 00:13:34 2003
+++ llvm/include/llvm/Target/MRegisterInfo.h Wed Jul 30 00:29:45 2003
@@ -169,14 +169,13 @@
//
/// Register class iterators
+ ///
regclass_iterator regclass_begin() const { return RegClassBegin; }
regclass_iterator regclass_end() const { return RegClassEnd; }
unsigned getNumRegClasses() const {
return regclass_end()-regclass_begin();
}
- virtual const TargetRegisterClass* getRegClassForType(const Type* Ty) const=0;
-
//===--------------------------------------------------------------------===//
// Interfaces used by the register allocator and stack frame manipulation
From lattner at cs.uiuc.edu Wed Jul 30 00:34:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 00:34:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp
Message-ID: <200307300533.AAA00801@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Target/X86:
InstSelectSimple.cpp updated: 1.117 -> 1.118
---
Log message:
Use target specific interface instead of forcing it to be target-generic
---
Diffs of the changes:
Index: llvm/lib/Target/X86/InstSelectSimple.cpp
diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.117 llvm/lib/Target/X86/InstSelectSimple.cpp:1.118
--- llvm/lib/Target/X86/InstSelectSimple.cpp:1.117 Sat Jul 26 18:49:58 2003
+++ llvm/lib/Target/X86/InstSelectSimple.cpp Wed Jul 30 00:33:48 2003
@@ -219,9 +219,12 @@
/// of the long value.
///
unsigned makeAnotherReg(const Type *Ty) {
+ assert(dynamic_cast(TM.getRegisterInfo()) &&
+ "Current target doesn't have X86 reg info??");
+ const X86RegisterInfo *MRI =
+ static_cast(TM.getRegisterInfo());
if (Ty == Type::LongTy || Ty == Type::ULongTy) {
- const TargetRegisterClass *RC =
- TM.getRegisterInfo()->getRegClassForType(Type::IntTy);
+ const TargetRegisterClass *RC = MRI->getRegClassForType(Type::IntTy);
// Create the lower part
F->getSSARegMap()->createVirtualRegister(RC);
// Create the upper part.
@@ -229,8 +232,7 @@
}
// Add the mapping of regnumber => reg class to MachineFunction
- const TargetRegisterClass *RC =
- TM.getRegisterInfo()->getRegClassForType(Ty);
+ const TargetRegisterClass *RC = MRI->getRegClassForType(Ty);
return F->getSSARegMap()->createVirtualRegister(RC);
}
From lattner at cs.uiuc.edu Wed Jul 30 00:50:02 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 00:50:02 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/Makefile
Message-ID: <200307300549.AAA04124@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Target/Sparc:
Makefile updated: 1.25 -> 1.26
---
Log message:
Only regenerate the .inc file if IT has changed, not just if the .td files
have changed.
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/Makefile
diff -u llvm/lib/Target/Sparc/Makefile:1.25 llvm/lib/Target/Sparc/Makefile:1.26
--- llvm/lib/Target/Sparc/Makefile:1.25 Tue Jul 29 18:04:41 2003
+++ llvm/lib/Target/Sparc/Makefile Wed Jul 30 00:49:17 2003
@@ -43,9 +43,18 @@
SparcV9CodeEmitter.cpp: SparcV9CodeEmitter.inc
-SparcV9CodeEmitter.inc: SparcV9.td SparcV9_F2.td SparcV9_F3.td SparcV9_F4.td SparcV9_Reg.td $(TBLGEN)
- @${ECHO} "TableGen-erating $@"
- $(CC) -E -xc -P SparcV9.td | $(TBLGEN) -gen-emitter -o $@
+
+TARGET_NAME := SparcV9
+
+TABLEGEN_FILES := $(wildcard *.td)
+
+$(TARGET_NAME)CodeEmitter.inc.tmp: $(TABLEGEN_FILES) $(TBLGEN)
+ @${ECHO} "TableGen-erating " $(TARGET_NAME)
+ $(CC) -E -xc -P $(TARGET_NAME).td | $(TBLGEN) -gen-emitter -o $@
+
+$(TARGET_NAME)CodeEmitter.inc: $(TARGET_NAME)CodeEmitter.inc.tmp
+ $(VERB) # Only copy over the real .inc file if it has changed!
+ $(VERB) diff $@ $< > /dev/null || cp $< $@
clean::
- ${RM} -f SparcV9CodeEmitter.inc
+ ${RM} -f $(TARGET_NAME)CodeEmitter.inc $(TARGET_NAME)CodeEmitter.inc.tmp
From lattner at cs.uiuc.edu Wed Jul 30 00:51:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 00:51:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Target.td
Message-ID: <200307300550.AAA04141@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Target:
Target.td updated: 1.4 -> 1.5
---
Log message:
Add all of the necessary classes to describe the contents of the MRegister.h implementation
for a target.
---
Diffs of the changes:
Index: llvm/lib/Target/Target.td
diff -u llvm/lib/Target/Target.td:1.4 llvm/lib/Target/Target.td:1.5
--- llvm/lib/Target/Target.td:1.4 Tue Jul 29 18:07:13 2003
+++ llvm/lib/Target/Target.td Wed Jul 30 00:50:12 2003
@@ -5,9 +5,14 @@
//
//===----------------------------------------------------------------------===//
+
+//===----------------------------------------------------------------------===//
+//
// Value types - These values correspond to the register types defined in the
// ValueTypes.h file.
+
class ValueType { string Namespace = "MVT"; }
+
def i1 : ValueType; // One bit boolean value
def i8 : ValueType; // 8-bit integer value
def i16 : ValueType; // 16-bit integer value
@@ -19,10 +24,44 @@
def f80 : ValueType; // 80-bit floating point value
def f128 : ValueType; // 128-bit floating point value
+
+//===----------------------------------------------------------------------===//
+// Register file description - These classes are used to fill in the target
+// description classes in llvm/Target/MRegisterInfo.h
+
+
+// Register - You should define one instance of this class for each register in
+// the target machine.
+//
class Register {
string Namespace = "";
- ValueType RegType;
}
+
+// RegisterAliases - You should define instances of this class to indicate which
+// registers in the register file are aliased together. This allows the code
+// generator to be careful not to put two values with overlapping live ranges
+// into registers which alias.
+//
+class RegisterAliases aliases> {
+ Register Reg = reg;
+ list Aliases = aliases;
+}
+
+// RegisterClass - Now that all of the registers are defined, and aliases
+// between registers are defined, specify which registers belong to which
+// register classes. This also defines the default allocation order of
+// registers by register allocators.
+//
+class RegisterClass regList> {
+ ValueType RegType = regType;
+ int Alignment = alignment;
+ list MemberList = regList;
+}
+
+
+//===----------------------------------------------------------------------===//
+// Instruction set description -
+//
class Instruction {
string Name; // The opcode string for this instruction
From lattner at cs.uiuc.edu Wed Jul 30 00:52:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 00:52:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcV9_Reg.td
Message-ID: <200307300551.AAA04154@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Target/Sparc:
SparcV9_Reg.td updated: 1.2 -> 1.3
---
Log message:
Conform to the new interface for describing target registers... even though
it's currently not used.
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/SparcV9_Reg.td
diff -u llvm/lib/Target/Sparc/SparcV9_Reg.td:1.2 llvm/lib/Target/Sparc/SparcV9_Reg.td:1.3
--- llvm/lib/Target/Sparc/SparcV9_Reg.td:1.2 Sun Jul 27 23:25:36 2003
+++ llvm/lib/Target/Sparc/SparcV9_Reg.td Wed Jul 30 00:51:34 2003
@@ -6,21 +6,31 @@
// Declarations that describe the Sparc register file
//===----------------------------------------------------------------------===//
-class V9Reg : Register { set Namespace = "SparcV9"; }
-
// Ri - One of the 32 64 bit integer registers
-class Ri num> : V9Reg {
- set RegType = i64; // All integer registers are 64 bits in size
+class Ri num> : Register {
field bits<5> Num = num; // Numbers are identified with a 5 bit ID
}
-def G0 : Ri< 0>; def G1 : Ri< 1>; def G2 : Ri< 2>; def G3 : Ri< 3>;
-def G4 : Ri< 4>; def G5 : Ri< 5>; def G6 : Ri< 6>; def G7 : Ri< 7>;
-def O0 : Ri< 8>; def O1 : Ri< 9>; def O2 : Ri<10>; def O3 : Ri<11>;
-def O4 : Ri<12>; def O5 : Ri<13>; def O6 : Ri<14>; def O7 : Ri<15>;
-def L0 : Ri<16>; def L1 : Ri<17>; def L2 : Ri<18>; def L3 : Ri<19>;
-def L4 : Ri<20>; def L5 : Ri<21>; def L6 : Ri<22>; def L7 : Ri<23>;
-def I0 : Ri<24>; def I1 : Ri<25>; def I2 : Ri<26>; def I3 : Ri<27>;
-def I4 : Ri<28>; def I5 : Ri<29>; def I6 : Ri<30>; def I7 : Ri<31>;
-// Floating-point registers?
-// ...
+set Namespace = "SparcV9" in {
+ def G0 : Ri< 0>; def G1 : Ri< 1>; def G2 : Ri< 2>; def G3 : Ri< 3>;
+ def G4 : Ri< 4>; def G5 : Ri< 5>; def G6 : Ri< 6>; def G7 : Ri< 7>;
+ def O0 : Ri< 8>; def O1 : Ri< 9>; def O2 : Ri<10>; def O3 : Ri<11>;
+ def O4 : Ri<12>; def O5 : Ri<13>; def O6 : Ri<14>; def O7 : Ri<15>;
+ def L0 : Ri<16>; def L1 : Ri<17>; def L2 : Ri<18>; def L3 : Ri<19>;
+ def L4 : Ri<20>; def L5 : Ri<21>; def L6 : Ri<22>; def L7 : Ri<23>;
+ def I0 : Ri<24>; def I1 : Ri<25>; def I2 : Ri<26>; def I3 : Ri<27>;
+ def I4 : Ri<28>; def I5 : Ri<29>; def I6 : Ri<30>; def I7 : Ri<31>;
+ // Floating-point registers?
+ // ...
+}
+
+
+// For fun, specify a register class.
+//
+// FIXME: the register order should be defined in terms of the prefered
+// allocation order...
+//
+def IntRegs : RegisterClass;
From vadve at cs.uiuc.edu Wed Jul 30 07:50:01 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Wed Jul 30 07:50:01 2003
Subject: [llvm-commits] CVS: llvm/test/Libraries/libinstr/tracelib.c
Message-ID: <200307301249.HAA04973@psmith.cs.uiuc.edu>
Changes in directory llvm/test/Libraries/libinstr:
tracelib.c updated: 1.9 -> 1.10
---
Log message:
1. Make table size prime -- improves hashing performance vastly.
2. Reduce #hashes from 2 to 1 for initial inserts.
3. Fix incorrect assertion from last checkin.
---
Diffs of the changes:
Index: llvm/test/Libraries/libinstr/tracelib.c
diff -u llvm/test/Libraries/libinstr/tracelib.c:1.9 llvm/test/Libraries/libinstr/tracelib.c:1.10
--- llvm/test/Libraries/libinstr/tracelib.c:1.9 Tue Jul 29 15:01:01 2003
+++ llvm/test/Libraries/libinstr/tracelib.c Wed Jul 30 07:49:25 2003
@@ -46,6 +46,16 @@
const FULLEMPTY EMPTY = '\0';
const FULLEMPTY FULL = '\1';
+// List of primes closest to powers of 2 in [2^20 -- 2^30], obtained from
+// http://www.utm.edu/research/primes/lists/2small/0bit.html.
+// Use these as the successive sizes of the hash table.
+#define NUMPRIMES 11
+#define FIRSTENTRY 2
+const uint PRIMES[NUMPRIMES] = { (1<<20)-3, (1<<21)-9, (1<<22)-3, (1<<23)-15,
+ (1<<24)-3, (1<<25)-39, (1<<26)-5, (1<<27)-39,
+ (1<<28)-57, (1<<29)-3, (1<<30)-35 };
+uint CurrentSizeEntry = FIRSTENTRY;
+
const uint MAX_NUM_PROBES = 4;
typedef struct PtrValueHashEntry_struct {
@@ -61,17 +71,17 @@
} PtrValueHashTable;
-extern Generic LookupOrInsertPtr(PtrValueHashTable* ptrTable,
- void* ptr, ACTION action);
+static Generic LookupOrInsertPtr(PtrValueHashTable* ptrTable, void* ptr,
+ ACTION action, Generic value);
-extern void Insert(PtrValueHashTable* ptrTable, void* ptr, Generic value);
+static void Insert(PtrValueHashTable* ptrTable, void* ptr, Generic value);
-extern void Delete(PtrValueHashTable* ptrTable, void* ptr);
+static void Delete(PtrValueHashTable* ptrTable, void* ptr);
-/* Returns NULL if the item is not found. */
+/* Returns 0 if the item is not found. */
/* void* LookupPtr(PtrValueHashTable* ptrTable, void* ptr) */
#define LookupPtr(ptrTable, ptr) \
- LookupOrInsertPtr(ptrTable, ptr, FIND)
+ LookupOrInsertPtr(ptrTable, ptr, FIND, (Generic) 0)
void
InitializeTable(PtrValueHashTable* ptrTable, Index newSize)
@@ -120,7 +130,7 @@
#ifndef NDEBUG
for (i=0; i < oldCapacity; ++i)
- if (! oldFlags[i])
+ if (oldFlags[i] == FULL)
assert(LookupPtr(ptrTable, oldTable[i].key) == oldTable[i].value);
#endif
@@ -151,8 +161,8 @@
DeleteAtIndex(PtrValueHashTable* ptrTable, Index index)
{
assert(ptrTable->fullEmptyFlags[index] == FULL && "Deleting empty slot!");
- ptrTable->table[index].key = NULL;
- ptrTable->table[index].value = (Generic) NULL;
+ ptrTable->table[index].key = 0;
+ ptrTable->table[index].value = (Generic) 0;
ptrTable->fullEmptyFlags[index] = EMPTY;
ptrTable->size--;
}
@@ -185,7 +195,11 @@
if (numProbes == MAX_NUM_PROBES)
{ /* table is too full: reallocate and search again */
- ReallocTable(ptrTable, 1 + 2*ptrTable->capacity);
+ if (CurrentSizeEntry >= NUMPRIMES-1) {
+ fprintf(stderr, "Out of PRIME Numbers!!!");
+ abort();
+ }
+ ReallocTable(ptrTable, PRIMES[++CurrentSizeEntry]);
return FindIndex(ptrTable, ptr);
}
else
@@ -196,8 +210,13 @@
}
}
+/* Look up hash table using 'ptr' as the key. If an entry exists, return
+ * the value mapped to 'ptr'. If not, and if action==ENTER is specified,
+ * create a new entry with value 'value', but return 0 in any case.
+ */
Generic
-LookupOrInsertPtr(PtrValueHashTable* ptrTable, void* ptr, ACTION action)
+LookupOrInsertPtr(PtrValueHashTable* ptrTable, void* ptr, ACTION action,
+ Generic value)
{
Index index = FindIndex(ptrTable, ptr);
if (ptrTable->fullEmptyFlags[index] == FULL &&
@@ -205,12 +224,11 @@
return ptrTable->table[index].value;
/* Lookup failed: item is not in the table */
- if (action != ENTER)
- return (Generic) NULL;
-
- /* Insert item into the table and return its index */
- InsertAtIndex(ptrTable, ptr, (Generic) NULL, index);
- return (Generic) NULL;
+ /* If action is ENTER, insert item into the table. Return 0 in any case. */
+ if (action == ENTER)
+ InsertAtIndex(ptrTable, ptr, value, index);
+
+ return (Generic) 0;
}
void
@@ -238,7 +256,7 @@
*===---------------------------------------------------------------------===*/
PtrValueHashTable* SequenceNumberTable = NULL;
-Index INITIAL_SIZE = 1 << 22;
+#define INITIAL_SIZE (PRIMES[FIRSTENTRY])
#define MAX_NUM_SAVED 1024
@@ -259,12 +277,13 @@
assert(MAX_NUM_PROBES < INITIAL_SIZE+1 && "Initial size too small");
SequenceNumberTable = CreateTable(INITIAL_SIZE);
}
- seqnum = (SequenceNumber) LookupPtr(SequenceNumberTable, ptr);
- if (seqnum == 0)
- {
- Insert(SequenceNumberTable, ptr, ++count);
- seqnum = count;
- }
+ seqnum = (SequenceNumber)
+ LookupOrInsertPtr(SequenceNumberTable, ptr, ENTER, count+1);
+
+ if (seqnum == 0) /* new entry was created with value count+1 */
+ seqnum = ++count; /* so increment counter */
+
+ assert(seqnum <= count && "Invalid sequence number in table!");
return seqnum;
}
From vadve at cs.uiuc.edu Wed Jul 30 07:55:00 2003
From: vadve at cs.uiuc.edu (Vikram Adve)
Date: Wed Jul 30 07:55:00 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/EmitAssembly.cpp
Message-ID: <200307301254.HAA05026@psmith.cs.uiuc.edu>
Changes in directory llvm/lib/Target/Sparc:
EmitAssembly.cpp updated: 1.85 -> 1.86
---
Log message:
When emitting a constant, check for ConstantExpr before
ordinary (primitive) types since ConstantExprs may be of primitive type!
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/EmitAssembly.cpp
diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.85 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.86
--- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.85 Tue Jul 29 14:57:34 2003
+++ llvm/lib/Target/Sparc/EmitAssembly.cpp Wed Jul 30 07:54:47 2003
@@ -714,7 +714,21 @@
toAsm << "\t" << TypeToDataDirective(CV->getType()) << "\t";
- if (CV->getType()->isPrimitiveType())
+ if (const ConstantPointerRef* CPR = dyn_cast(CV))
+ { // This is a constant address for a global variable or method.
+ // Use the name of the variable or method as the address value.
+ assert(isa(CPR->getValue()) && "Unexpected non-global");
+ toAsm << getID(CPR->getValue()) << "\n";
+ }
+ else if (isa(CV))
+ { // Null pointer value
+ toAsm << "0\n";
+ }
+ else if (const ConstantExpr* CE = dyn_cast(CV))
+ { // Constant expression built from operators, constants, and symbolic addrs
+ toAsm << ConstantExprToString(CE, Target) << "\n";
+ }
+ else if (CV->getType()->isPrimitiveType()) // Check primitive types last
{
if (CV->getType()->isFloatingPoint()) {
// FP Constants are printed as integer constants to avoid losing
@@ -736,19 +750,6 @@
} else {
WriteAsOperand(toAsm, CV, false, false) << "\n";
}
- }
- else if (const ConstantPointerRef* CPR = dyn_cast(CV))
- { // This is a constant address for a global variable or method.
- // Use the name of the variable or method as the address value.
- toAsm << getID(CPR->getValue()) << "\n";
- }
- else if (isa(CV))
- { // Null pointer value
- toAsm << "0\n";
- }
- else if (const ConstantExpr* CE = dyn_cast(CV))
- { // Constant expression built from operators, constants, and symbolic addrs
- toAsm << ConstantExprToString(CE, Target) << "\n";
}
else
{
From brukman at cs.uiuc.edu Wed Jul 30 10:31:02 2003
From: brukman at cs.uiuc.edu (Misha Brukman)
Date: Wed Jul 30 10:31:02 2003
Subject: [llvm-commits] CVS: llvm/tools/llc/llc.cpp
Message-ID: <200307301530.KAA21344@zion.cs.uiuc.edu>
Changes in directory llvm/tools/llc:
llc.cpp updated: 1.79 -> 1.80
---
Log message:
Revert change: default architecture is never set, it is guessed from input
bytecode file. This means that LLC on X86 will compile to Sparc assembly given a
64-bit input bytecode file...
---
Diffs of the changes:
Index: llvm/tools/llc/llc.cpp
diff -u llvm/tools/llc/llc.cpp:1.79 llvm/tools/llc/llc.cpp:1.80
--- llvm/tools/llc/llc.cpp:1.79 Fri Jul 18 17:21:40 2003
+++ llvm/tools/llc/llc.cpp Wed Jul 30 10:29:55 2003
@@ -35,14 +35,7 @@
cl::values(clEnumVal(x86, " IA-32 (Pentium and above)"),
clEnumValN(Sparc, "sparc", " SPARC V9"),
0),
-#if defined(i386) || defined(__i386__) || defined(__x86__)
- cl::init(x86)
-#elif defined(sparc) || defined(__sparc__) || defined(__sparcv9)
- cl::init(Sparc)
-#else
- cl::init(noarch)
-#endif
- );
+ cl::init(noarch));
// GetFileNameRoot - Helper function to get the basename of a filename...
static inline std::string
From criswell at cs.uiuc.edu Wed Jul 30 10:56:01 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Wed Jul 30 10:56:01 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT2000/255.vortex/Makefile
Message-ID: <200307301555.KAA09143@morpheus.cs.uiuc.edu>
Changes in directory llvm/test/Programs/External/SPEC/CINT2000/255.vortex:
Makefile updated: 1.4 -> 1.5
---
Log message:
Modified the benchmark to use the big endian input file on Sparc.
Using the little endian input file causes an error to be printed, which in
turn causes vortext to segfault.
---
Diffs of the changes:
Index: llvm/test/Programs/External/SPEC/CINT2000/255.vortex/Makefile
diff -u llvm/test/Programs/External/SPEC/CINT2000/255.vortex/Makefile:1.4 llvm/test/Programs/External/SPEC/CINT2000/255.vortex/Makefile:1.5
--- llvm/test/Programs/External/SPEC/CINT2000/255.vortex/Makefile:1.4 Fri Jul 4 06:18:55 2003
+++ llvm/test/Programs/External/SPEC/CINT2000/255.vortex/Makefile Wed Jul 30 10:55:36 2003
@@ -1,8 +1,16 @@
LEVEL = ../../../../../..
-RUN_OPTIONS = lendian.raw
#STDOUT_FILENAME := input.random.out
+
include ../../Makefile.spec
+
ifeq ($(ARCH),Sparc)
## SPEC portability note for vortex says to use this flag on 64-bit machines
CPPFLAGS += -DSPEC_CPU2000_LP64
+
+ # If we're on sparc, use the Big Endian input file
+ RUN_OPTIONS = bendian.raw
+else
+ # Use the Little Endian input file
+ RUN_OPTIONS = lendian.raw
endif
+
From lattner at cs.uiuc.edu Wed Jul 30 12:35:02 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 12:35:02 2003
Subject: [llvm-commits] CVS: llvm/lib/Support/CommandLine.cpp
Message-ID: <200307301734.MAA10074@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Support:
CommandLine.cpp updated: 1.33 -> 1.34
---
Log message:
Add support for "named positional arguments"
---
Diffs of the changes:
Index: llvm/lib/Support/CommandLine.cpp
diff -u llvm/lib/Support/CommandLine.cpp:1.33 llvm/lib/Support/CommandLine.cpp:1.34
--- llvm/lib/Support/CommandLine.cpp:1.33 Thu Jul 10 16:38:28 2003
+++ llvm/lib/Support/CommandLine.cpp Wed Jul 30 12:34:02 2003
@@ -96,9 +96,9 @@
return Handler->addOccurrence(ArgName, Value);
}
-static bool ProvidePositionalOption(Option *Handler, std::string &Arg) {
+static bool ProvidePositionalOption(Option *Handler, const std::string &Arg) {
int Dummy;
- return ProvideOption(Handler, "", Arg.c_str(), 0, 0, Dummy);
+ return ProvideOption(Handler, Handler->ArgStr, Arg.c_str(), 0, 0, Dummy);
}
@@ -189,9 +189,10 @@
Opt->error(" error - this positional option will never be matched, "
"because it does not Require a value, and a "
"cl::ConsumeAfter option is active!");
- } else if (UnboundedFound) { // This option does not "require" a value...
- // Make sure this option is not specified after an option that eats all
- // extra arguments, or this one will never get any!
+ } else if (UnboundedFound && !Opt->ArgStr[0]) {
+ // This option does not "require" a value... Make sure this option is
+ // not specified after an option that eats all extra arguments, or this
+ // one will never get any!
//
ErrorParsing |= Opt->error(" error - option can never match, because "
"another positional argument will match an "
@@ -207,6 +208,11 @@
//
std::vector PositionalVals;
+ // If the program has named positional arguments, and the name has been run
+ // across, keep track of which positional argument was named. Otherwise put
+ // the positional args into the PositionalVals list...
+ Option *ActivePositionalArg = 0;
+
// Loop over all of the arguments... processing them.
bool DashDashFound = false; // Have we read '--'?
for (int i = 1; i < argc; ++i) {
@@ -220,7 +226,10 @@
//
if (argv[i][0] != '-' || argv[i][1] == 0 || DashDashFound) {
// Positional argument!
- if (!PositionalOpts.empty()) {
+ if (ActivePositionalArg) {
+ ProvidePositionalOption(ActivePositionalArg, argv[i]);
+ continue; // We are done!
+ } else if (!PositionalOpts.empty()) {
PositionalVals.push_back(argv[i]);
// All of the positional arguments have been fulfulled, give the rest to
@@ -338,7 +347,13 @@
Pos = Val.find(',');
}
}
- ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i);
+
+ // If this is a named positional argument, just remember that it is the
+ // active one...
+ if (Handler->getFormattingFlag() == cl::Positional)
+ ActivePositionalArg = Handler;
+ else
+ ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i);
}
// Check and handle positional arguments now...
@@ -469,21 +484,22 @@
void Option::addArgument(const char *ArgStr) {
if (ArgStr[0])
AddArgument(ArgStr, this);
- else if (getFormattingFlag() == Positional)
+
+ if (getFormattingFlag() == Positional)
getPositionalOpts().push_back(this);
else if (getNumOccurrencesFlag() == ConsumeAfter) {
- assert((getPositionalOpts().empty() ||
- getPositionalOpts().front()->getNumOccurrencesFlag() != ConsumeAfter)
- && "Cannot specify more than one option with cl::ConsumeAfter "
- "specified!");
+ if (!getPositionalOpts().empty() &&
+ getPositionalOpts().front()->getNumOccurrencesFlag() == ConsumeAfter)
+ error("Cannot specify more than one option with cl::ConsumeAfter!");
getPositionalOpts().insert(getPositionalOpts().begin(), this);
}
}
void Option::removeArgument(const char *ArgStr) {
- if (ArgStr[0]) {
+ if (ArgStr[0])
RemoveArgument(ArgStr, this);
- } else if (getFormattingFlag() == Positional) {
+
+ if (getFormattingFlag() == Positional) {
std::vector::iterator I =
std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this);
assert(I != getPositionalOpts().end() && "Arg not registered!");
@@ -738,8 +754,11 @@
if (!PosOpts.empty() && PosOpts[0]->getNumOccurrencesFlag() == ConsumeAfter)
CAOpt = PosOpts[0];
- for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i)
+ for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) {
+ if (PosOpts[i]->ArgStr[0])
+ std::cerr << " --" << PosOpts[i]->ArgStr;
std::cerr << " " << PosOpts[i]->HelpStr;
+ }
// Print the consume after option info if it exists...
if (CAOpt) std::cerr << " " << CAOpt->HelpStr;
From lattner at cs.uiuc.edu Wed Jul 30 12:37:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 12:37:01 2003
Subject: [llvm-commits] CVS: llvm/tools/bugpoint/bugpoint.cpp
Message-ID: <200307301736.MAA10098@apoc.cs.uiuc.edu>
Changes in directory llvm/tools/bugpoint:
bugpoint.cpp updated: 1.3 -> 1.4
---
Log message:
Add variable to capture arguments that should be passed to the user program
This is unused so far.
---
Diffs of the changes:
Index: llvm/tools/bugpoint/bugpoint.cpp
diff -u llvm/tools/bugpoint/bugpoint.cpp:1.3 llvm/tools/bugpoint/bugpoint.cpp:1.4
--- llvm/tools/bugpoint/bugpoint.cpp:1.3 Thu Jul 24 13:17:43 2003
+++ llvm/tools/bugpoint/bugpoint.cpp Wed Jul 30 12:36:07 2003
@@ -20,8 +20,11 @@
static cl::list
PassList(cl::desc("Passes available:"), cl::ZeroOrMore);
-//cl::list
-//InputArgv(cl::ConsumeAfter, cl::desc("..."));
+// Anything specified after the --args option are taken as arguments to the
+// program being debugged.
+cl::list
+InputArgv("args", cl::Positional, cl::desc("..."),
+ cl::ZeroOrMore);
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv);
From brukman at cs.uiuc.edu Wed Jul 30 12:45:01 2003
From: brukman at cs.uiuc.edu (Misha Brukman)
Date: Wed Jul 30 12:45:01 2003
Subject: [llvm-commits] CVS: llvm/tools/bugpoint/ExecutionDriver.cpp
Message-ID: <200307301744.MAA23439@zion.cs.uiuc.edu>
Changes in directory llvm/tools/bugpoint:
ExecutionDriver.cpp updated: 1.9 -> 1.10
---
Log message:
Use a vector instead of char*[] so that we can add arbitrary number of
parameters, such as command-line arguments that the executing program gets via
bugpoint.
---
Diffs of the changes:
Index: llvm/tools/bugpoint/ExecutionDriver.cpp
diff -u llvm/tools/bugpoint/ExecutionDriver.cpp:1.9 llvm/tools/bugpoint/ExecutionDriver.cpp:1.10
--- llvm/tools/bugpoint/ExecutionDriver.cpp:1.9 Mon Jul 28 14:16:14 2003
+++ llvm/tools/bugpoint/ExecutionDriver.cpp Wed Jul 30 12:44:15 2003
@@ -43,6 +43,8 @@
enum FileType { AsmFile, CFile };
}
+extern cl::list InputArgv;
+
/// AbstractInterpreter Class - Subclasses of this class are used to execute
/// LLVM bytecode in a variety of ways. This abstract interface hides this
/// complexity behind a simple interface.
@@ -93,17 +95,19 @@
exit(1);
}
- const char *Args[] = {
- LLIPath.c_str(),
- "-abort-on-exception",
- "-quiet",
- "-force-interpreter=true",
- Bytecode.c_str(),
- 0
- };
+ std::vector Args;
+ Args.push_back(LLIPath.c_str());
+ Args.push_back("-abort-on-exception");
+ Args.push_back("-quiet");
+ Args.push_back("-force-interpreter=true");
+ Args.push_back(Bytecode.c_str());
+ // Add optional parameters to the running program from Argv
+ for (unsigned i=0, e = InputArgv.size(); i != e; ++i)
+ Args.push_back(InputArgv[i].c_str());
+ Args.push_back(0);
std::cout << "";
- return RunProgramWithTimeout(LLIPath, Args,
+ return RunProgramWithTimeout(LLIPath, &Args[0],
InputFile, OutputFile, OutputFile);
}
@@ -148,44 +152,37 @@
const std::string &OutputFile,
const std::string &SharedLib) {
std::string OutputBinary = getUniqueFilename("bugpoint.gcc.exe");
- const char **GCCArgs;
+ std::vector GCCArgs;
- const char *ArgsWithoutSO[] = {
- GCCPath.c_str(),
- "-x", (fileType == AsmFile) ? "assembler" : "c",
- ProgramFile.c_str(), // Specify the input filename...
- "-o", OutputBinary.c_str(), // Output to the right filename...
- "-lm", // Hard-code the math library...
- "-O2", // Optimize the program a bit...
- 0
- };
- const char *ArgsWithSO[] = {
- GCCPath.c_str(),
- SharedLib.c_str(), // Specify the shared library to link in...
- "-x", (fileType == AsmFile) ? "assembler" : "c",
- ProgramFile.c_str(), // Specify the input filename...
- "-o", OutputBinary.c_str(), // Output to the right filename...
- "-lm", // Hard-code the math library...
- "-O2", // Optimize the program a bit...
- 0
- };
+ GCCArgs.push_back(GCCPath.c_str());
+ if (!SharedLib.empty()) // Specify the shared library to link in...
+ GCCArgs.push_back(SharedLib.c_str());
+ GCCArgs.push_back("-x");
+ GCCArgs.push_back((fileType == AsmFile) ? "assembler" : "c");
+ GCCArgs.push_back(ProgramFile.c_str()); // Specify the input filename...
+ GCCArgs.push_back("-o");
+ GCCArgs.push_back(OutputBinary.c_str()); // Output to the right file...
+ GCCArgs.push_back("-lm"); // Hard-code the math library...
+ GCCArgs.push_back("-O2"); // Optimize the program a bit...
+ GCCArgs.push_back(0); // NULL terminator
- GCCArgs = (SharedLib.empty()) ? ArgsWithoutSO : ArgsWithSO;
std::cout << "";
- if (RunProgramWithTimeout(GCCPath, GCCArgs, "/dev/null", "/dev/null",
+ if (RunProgramWithTimeout(GCCPath, &GCCArgs[0], "/dev/null", "/dev/null",
"/dev/null")) {
- ProcessFailure(GCCArgs);
+ ProcessFailure(&GCCArgs[0]);
exit(1);
}
- const char *ProgramArgs[] = {
- OutputBinary.c_str(),
- 0
- };
+ std::vector ProgramArgs;
+ ProgramArgs.push_back(OutputBinary.c_str());
+ // Add optional parameters to the running program from Argv
+ for (unsigned i=0, e = InputArgv.size(); i != e; ++i)
+ ProgramArgs.push_back(InputArgv[i].c_str());
+ ProgramArgs.push_back(0); // NULL terminator
// Now that we have a binary, run it!
std::cout << "";
- int ProgramResult = RunProgramWithTimeout(OutputBinary, ProgramArgs,
+ int ProgramResult = RunProgramWithTimeout(OutputBinary, &ProgramArgs[0],
InputFile, OutputFile, OutputFile);
std::cout << "\n";
removeFile(OutputBinary);
From lattner at cs.uiuc.edu Wed Jul 30 12:56:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 12:56:01 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs
Message-ID: <200307301755.MAA10794@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs:
Makefile.programs updated: 1.78 -> 1.79
---
Log message:
Make it easier to debug the jit and LLC on test programs
---
Diffs of the changes:
Index: llvm/test/Programs/Makefile.programs
diff -u llvm/test/Programs/Makefile.programs:1.78 llvm/test/Programs/Makefile.programs:1.79
--- llvm/test/Programs/Makefile.programs:1.78 Fri Jul 25 17:39:50 2003
+++ llvm/test/Programs/Makefile.programs Wed Jul 30 12:55:27 2003
@@ -248,22 +248,35 @@
Output/gccas-pass-args: $(LGCCAS)
$(LGCCAS) /dev/null -o /dev/null -debug-pass=Arguments > $@.1 2>&1
sed 's/Pass Arguments: //' < $@.1 > $@
-Output/gccld-pass-args: $(LGCCLD)
+Output/gccld-pass-args: $(TOOLS)/gccld
$(LGCCLD) /dev/null -o /dev/null -debug-pass=Arguments > $@.1 2>&1
sed 's/Pass Arguments: //' < $@.1 > $@
+# Specify stdin, reference output, and command line options for the program...
+BUGPOINT_OPTIONS += -input=$(STDIN_FILENAME) -output=Output/$*.out-nat
+BUGPOINT_OPTIONS += --args -- $(RUN_OPTIONS)
+
+
# Rules to bugpoint the GCCAS or GCCLD command...
$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-gccas): \
Output/%.bugpoint-gccas: Output/%.linked.rll $(LBUGPOINT) \
Output/gccas-pass-args Output/%.out-nat
- $(LBUGPOINT) $< `cat Output/gccas-pass-args` $(BUGPOINT_OPTIONS) \
- -input=$(STDIN_FILENAME) -output=Output/$*.out-nat
+ $(LBUGPOINT) $< `cat Output/gccas-pass-args` $(BUGPOINT_OPTIONS)
+
$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-gccld): \
Output/%.bugpoint-gccld: Output/%.linked.bc $(LBUGPOINT) \
Output/gccld-pass-args Output/%.out-nat
- $(LBUGPOINT) $< `cat Output/gccld-pass-args` $(BUGPOINT_OPTIONS) \
- -input=$(STDIN_FILENAME) -output=Output/$*.out-nat
+ $(LBUGPOINT) $< `cat Output/gccld-pass-args` $(BUGPOINT_OPTIONS)
+
+$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-llc): \
+Output/%.bugpoint-llc: Output/%.linked.bc $(LBUGPOINT) Output/%.out-nat
+ $(LBUGPOINT) $< -run-llc -mode=codegen $(BUGPOINT_OPTIONS)
+
+$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-jit): \
+Output/%.bugpoint-jit: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat
+ $(LBUGPOINT) $< -run-jit -mode=codegen $(BUGPOINT_OPTIONS)
+
#
# Rules to compile the program for the C Back End
#
From lattner at cs.uiuc.edu Wed Jul 30 12:57:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 12:57:01 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Makefile.multisrc
Message-ID: <200307301756.MAA10857@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs/MultiSource:
Makefile.multisrc updated: 1.33 -> 1.34
---
Log message:
Add support for bugpointing LLC and the jit
---
Diffs of the changes:
Index: llvm/test/Programs/MultiSource/Makefile.multisrc
diff -u llvm/test/Programs/MultiSource/Makefile.multisrc:1.33 llvm/test/Programs/MultiSource/Makefile.multisrc:1.34
--- llvm/test/Programs/MultiSource/Makefile.multisrc:1.33 Fri Jun 20 14:01:07 2003
+++ llvm/test/Programs/MultiSource/Makefile.multisrc Wed Jul 30 12:56:11 2003
@@ -42,6 +42,8 @@
bugpoint-gccas: Output/$(PROG).bugpoint-gccas
bugpoint-gccld: Output/$(PROG).bugpoint-gccld
+bugpoint-jit: Output/$(PROG).bugpoint-jit
+bugpoint-llc: Output/$(PROG).bugpoint-llc
# Raw bytecode files are files created by simply linking the output of the GCC
# frontend without running gccas.
From lattner at cs.uiuc.edu Wed Jul 30 12:58:00 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 12:58:00 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs
Message-ID: <200307301757.MAA11069@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs:
Makefile.programs updated: 1.79 -> 1.80
---
Log message:
Oops, fix copy and pasto
---
Diffs of the changes:
Index: llvm/test/Programs/Makefile.programs
diff -u llvm/test/Programs/Makefile.programs:1.79 llvm/test/Programs/Makefile.programs:1.80
--- llvm/test/Programs/Makefile.programs:1.79 Wed Jul 30 12:55:27 2003
+++ llvm/test/Programs/Makefile.programs Wed Jul 30 12:57:14 2003
@@ -270,7 +270,7 @@
$(LBUGPOINT) $< `cat Output/gccld-pass-args` $(BUGPOINT_OPTIONS)
$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-llc): \
-Output/%.bugpoint-llc: Output/%.linked.bc $(LBUGPOINT) Output/%.out-nat
+Output/%.bugpoint-llc: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat
$(LBUGPOINT) $< -run-llc -mode=codegen $(BUGPOINT_OPTIONS)
$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-jit): \
From brukman at cs.uiuc.edu Wed Jul 30 13:00:00 2003
From: brukman at cs.uiuc.edu (Misha Brukman)
Date: Wed Jul 30 13:00:00 2003
Subject: [llvm-commits] CVS: llvm/tools/bugpoint/ExecutionDriver.cpp bugpoint.cpp
Message-ID: <200307301759.MAA14593@zion.cs.uiuc.edu>
Changes in directory llvm/tools/bugpoint:
ExecutionDriver.cpp updated: 1.10 -> 1.11
bugpoint.cpp updated: 1.4 -> 1.5
---
Log message:
Moved definition of InputArgv into ExecutionDriver.cpp -- it is only used there.
---
Diffs of the changes:
Index: llvm/tools/bugpoint/ExecutionDriver.cpp
diff -u llvm/tools/bugpoint/ExecutionDriver.cpp:1.10 llvm/tools/bugpoint/ExecutionDriver.cpp:1.11
--- llvm/tools/bugpoint/ExecutionDriver.cpp:1.10 Wed Jul 30 12:44:15 2003
+++ llvm/tools/bugpoint/ExecutionDriver.cpp Wed Jul 30 12:59:23 2003
@@ -40,10 +40,14 @@
InputFile("input", cl::init("/dev/null"),
cl::desc("Filename to pipe in as stdin (default: /dev/null)"));
+ // Anything specified after the --args option are taken as arguments to the
+ // program being debugged.
+ cl::list
+ InputArgv("args", cl::Positional, cl::desc("..."),
+ cl::ZeroOrMore);
+
enum FileType { AsmFile, CFile };
}
-
-extern cl::list InputArgv;
/// AbstractInterpreter Class - Subclasses of this class are used to execute
/// LLVM bytecode in a variety of ways. This abstract interface hides this
Index: llvm/tools/bugpoint/bugpoint.cpp
diff -u llvm/tools/bugpoint/bugpoint.cpp:1.4 llvm/tools/bugpoint/bugpoint.cpp:1.5
--- llvm/tools/bugpoint/bugpoint.cpp:1.4 Wed Jul 30 12:36:07 2003
+++ llvm/tools/bugpoint/bugpoint.cpp Wed Jul 30 12:59:23 2003
@@ -20,12 +20,6 @@
static cl::list
PassList(cl::desc("Passes available:"), cl::ZeroOrMore);
-// Anything specified after the --args option are taken as arguments to the
-// program being debugged.
-cl::list
-InputArgv("args", cl::Positional, cl::desc("..."),
- cl::ZeroOrMore);
-
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv);
From lattner at cs.uiuc.edu Wed Jul 30 14:05:02 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 14:05:02 2003
Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
Message-ID: <200307301904.OAA06421@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/VMCore:
Constants.cpp updated: 1.47 -> 1.48
---
Log message:
Fix a bug that brian reported
---
Diffs of the changes:
Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.47 llvm/lib/VMCore/Constants.cpp:1.48
--- llvm/lib/VMCore/Constants.cpp:1.47 Wed Jul 23 10:22:26 2003
+++ llvm/lib/VMCore/Constants.cpp Wed Jul 30 14:04:37 2003
@@ -463,6 +463,26 @@
//===----------------------------------------------------------------------===//
// Factory Function Implementation
+// ReplaceUsesOfWith - This is exactly the same as Value::replaceAllUsesWith,
+// except that it doesn't have all of the asserts. The asserts fail because we
+// are half-way done resolving types, which causes some types to exist as two
+// different Type*'s at the same time. This is a sledgehammer to work around
+// this problem.
+//
+static void ReplaceUsesOfWith(Value *Old, Value *New) {
+ while (!Old->use_empty()) {
+ User *Use = Old->use_back();
+ // Must handle Constants specially, we cannot call replaceUsesOfWith on a
+ // constant!
+ if (Constant *C = dyn_cast(Use)) {
+ C->replaceUsesOfWithOnConstant(Old, New);
+ } else {
+ Use->replaceUsesOfWith(Old, New);
+ }
+ }
+}
+
+
// ConstantCreator - A class that is used to create constants by
// ValueMap*. This class should be partially specialized if there is
// something strange that needs to be done to interface to the ctor for the
@@ -573,7 +593,7 @@
C.push_back(cast(getOperand(i)));
Constant *New = ConstantArray::get(cast(NewTy), C);
if (New != this) {
- replaceAllUsesWith(New);
+ ReplaceUsesOfWith(this, New);
destroyConstant(); // This constant is now dead, destroy it.
}
}
@@ -642,7 +662,7 @@
C.push_back(cast(getOperand(i)));
Constant *New = ConstantStruct::get(cast(NewTy), C);
if (New != this) {
- replaceAllUsesWith(New);
+ ReplaceUsesOfWith(this, New);
destroyConstant(); // This constant is now dead, destroy it.
}
}
@@ -683,7 +703,7 @@
// Make everyone now use a constant of the new type...
Constant *New = ConstantPointerNull::get(cast(NewTy));
if (New != this) {
- replaceAllUsesWith(New);
+ ReplaceUsesOfWith(this, New);
// This constant is now dead, destroy it.
destroyConstant();
@@ -836,7 +856,7 @@
New = ConstantExpr::getGetElementPtr(getOperand(0), C);
}
if (New != this) {
- replaceAllUsesWith(New);
+ ReplaceUsesOfWith(this, New);
destroyConstant(); // This constant is now dead, destroy it.
}
}
From lattner at cs.uiuc.edu Wed Jul 30 14:40:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 14:40:01 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileLexer.l
Message-ID: <200307301939.OAA11692@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
FileLexer.l updated: 1.1 -> 1.2
---
Log message:
Directly support C style comments in tblgen, but allow them to actually nest
---
Diffs of the changes:
Index: llvm/utils/TableGen/FileLexer.l
diff -u llvm/utils/TableGen/FileLexer.l:1.1 llvm/utils/TableGen/FileLexer.l:1.2
--- llvm/utils/TableGen/FileLexer.l:1.1 Sun Dec 1 19:23:04 2002
+++ llvm/utils/TableGen/FileLexer.l Wed Jul 30 14:39:36 2003
@@ -16,6 +16,7 @@
%option noreject
%option noyymore
+%x comment
%{
#include "Record.h"
@@ -29,6 +30,8 @@
return strtol(Str, 0, 0);
}
+static int CommentDepth = 0;
+
%}
Comment \/\/.*
@@ -63,4 +66,14 @@
[ \t\n]+ { /* Ignore whitespace */ }
. { return Filetext[0]; }
+
+
+"/*" { BEGIN(comment); CommentDepth++; }
+[^*/]* /* eat anything that's not a '*' or '/' */
+"*"+[^*/]* /* eat up '*'s not followed by '/'s */
+"/*" { ++CommentDepth; }
+"/"+[^*]* /* eat up /'s not followed by *'s */
+"*"+"/" { if (!--CommentDepth) { BEGIN(INITIAL); } }
+<> { fprintf(stderr, "Unterminated comment!\n"); abort(); }
+
%%
From lattner at cs.uiuc.edu Wed Jul 30 14:41:03 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 14:41:03 2003
Subject: [llvm-commits] CVS: llvm/test/Regression/TableGen/
Message-ID: <200307301940.OAA11709@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Regression/TableGen:
---
Log message:
Directory /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/test/Regression/TableGen added to the repository
---
Diffs of the changes:
From lattner at cs.uiuc.edu Wed Jul 30 14:41:08 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 14:41:08 2003
Subject: [llvm-commits] CVS: llvm/test/Regression/TableGen/CStyleComment.td Makefile UnterminatedComment.td
Message-ID: <200307301940.OAA11720@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Regression/TableGen:
CStyleComment.td added (r1.1)
Makefile added (r1.1)
UnterminatedComment.td added (r1.1)
---
Log message:
Initial tests for tblgen
---
Diffs of the changes:
Index: llvm/test/Regression/TableGen/CStyleComment.td
diff -c /dev/null llvm/test/Regression/TableGen/CStyleComment.td:1.1
*** /dev/null Wed Jul 30 14:40:11 2003
--- llvm/test/Regression/TableGen/CStyleComment.td Wed Jul 30 14:40:00 2003
***************
*** 0 ****
--- 1,14 ----
+ // Test that multiline, nested, comments work correctly.
+ //
+ // RUN: tblgen < %s
+
+ /* Foo
+ bar
+ /*
+ blah
+ */
+
+ stuff
+ */
+
+ def x;
Index: llvm/test/Regression/TableGen/Makefile
diff -c /dev/null llvm/test/Regression/TableGen/Makefile:1.1
*** /dev/null Wed Jul 30 14:40:11 2003
--- llvm/test/Regression/TableGen/Makefile Wed Jul 30 14:40:00 2003
***************
*** 0 ****
--- 1,10 ----
+
+ LEVEL = ../../..
+ include $(LEVEL)/test/Makefile.tests
+
+ TESTS := $(wildcard *.td)
+
+ all:: $(addprefix Output/, $(TESTS:%=%.out))
+
+ Output/%.out: % Output/.dir $(TBLGEN)
+ -$(TESTRUNR) $<
Index: llvm/test/Regression/TableGen/UnterminatedComment.td
diff -c /dev/null llvm/test/Regression/TableGen/UnterminatedComment.td:1.1
*** /dev/null Wed Jul 30 14:40:11 2003
--- llvm/test/Regression/TableGen/UnterminatedComment.td Wed Jul 30 14:40:00 2003
***************
*** 0 ****
--- 1,6 ----
+ // RUN: not tblgen < %s
+
+ def x;
+
+ /* /* /* */
+
From lattner at cs.uiuc.edu Wed Jul 30 14:49:00 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 14:49:00 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileParser.y TableGen.cpp
Message-ID: <200307301948.OAA12664@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
FileParser.y updated: 1.10 -> 1.11
TableGen.cpp updated: 1.8 -> 1.9
---
Log message:
Make tablegen take an input filename to parse if one is specified, otherwise
use stdin.
---
Diffs of the changes:
Index: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.10 llvm/utils/TableGen/FileParser.y:1.11
--- llvm/utils/TableGen/FileParser.y:1.10 Wed Jul 30 00:17:35 2003
+++ llvm/utils/TableGen/FileParser.y Wed Jul 30 14:48:02 2003
@@ -24,12 +24,24 @@
static std::vector*>,
Init*> > SetStack;
-void ParseFile() {
+void ParseFile(const std::string &Filename) {
FILE *F = stdin;
+ if (Filename != "-") {
+ F = fopen(Filename.c_str(), "r");
+
+ if (F == 0) {
+ std::cerr << "Could not open input file '" + Filename + "'!\n";
+ abort();
+ }
+ }
+
Filein = F;
Filelineno = 1;
Fileparse();
+
+ if (F != stdin)
+ fclose(F);
Filein = stdin;
}
Index: llvm/utils/TableGen/TableGen.cpp
diff -u llvm/utils/TableGen/TableGen.cpp:1.8 llvm/utils/TableGen/TableGen.cpp:1.9
--- llvm/utils/TableGen/TableGen.cpp:1.8 Tue Jul 29 18:00:08 2003
+++ llvm/utils/TableGen/TableGen.cpp Wed Jul 30 14:48:02 2003
@@ -29,13 +29,16 @@
Class("class", cl::desc("Print Enum list for this class"),
cl::value_desc("class name"));
- cl::opt
- OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"),
- cl::init("-"));
+ cl::opt
+ OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"),
+ cl::init("-"));
+
+ cl::opt
+ InputFilename(cl::Positional, cl::desc(" "), cl::init("-"));
}
-void ParseFile();
+void ParseFile(const std::string &Filename);
RecordKeeper Records;
@@ -379,7 +382,7 @@
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv);
- ParseFile();
+ ParseFile(InputFilename);
std::ostream *Out = &std::cout;
if (OutputFilename != "-") {
From lattner at cs.uiuc.edu Wed Jul 30 14:56:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 14:56:01 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileLexer.l FileParser.y
Message-ID: <200307301955.OAA14496@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
FileLexer.l updated: 1.2 -> 1.3
FileParser.y updated: 1.11 -> 1.12
---
Log message:
Minor reorganization, move ParseFile to the lexer
---
Diffs of the changes:
Index: llvm/utils/TableGen/FileLexer.l
diff -u llvm/utils/TableGen/FileLexer.l:1.2 llvm/utils/TableGen/FileLexer.l:1.3
--- llvm/utils/TableGen/FileLexer.l:1.2 Wed Jul 30 14:39:36 2003
+++ llvm/utils/TableGen/FileLexer.l Wed Jul 30 14:55:10 2003
@@ -32,6 +32,28 @@
static int CommentDepth = 0;
+int Fileparse();
+
+void ParseFile(const std::string &Filename) {
+ FILE *F = stdin;
+ if (Filename != "-") {
+ F = fopen(Filename.c_str(), "r");
+
+ if (F == 0) {
+ std::cerr << "Could not open input file '" + Filename + "'!\n";
+ abort();
+ }
+ }
+
+ Filein = F;
+ Filelineno = 1;
+ Fileparse();
+
+ if (F != stdin)
+ fclose(F);
+ Filein = stdin;
+}
+
%}
Comment \/\/.*
Index: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.11 llvm/utils/TableGen/FileParser.y:1.12
--- llvm/utils/TableGen/FileParser.y:1.11 Wed Jul 30 14:48:02 2003
+++ llvm/utils/TableGen/FileParser.y Wed Jul 30 14:55:10 2003
@@ -7,43 +7,19 @@
%{
#include "Record.h"
#include "Support/StringExtras.h"
-#include
#include
#include
#define YYERROR_VERBOSE 1
int yyerror(const char *ErrorMsg);
int yylex();
-extern FILE *Filein;
extern int Filelineno;
-int Fileparse();
static Record *CurRec = 0;
typedef std::pair*> SubClassRefTy;
static std::vector*>,
Init*> > SetStack;
-
-void ParseFile(const std::string &Filename) {
- FILE *F = stdin;
- if (Filename != "-") {
- F = fopen(Filename.c_str(), "r");
-
- if (F == 0) {
- std::cerr << "Could not open input file '" + Filename + "'!\n";
- abort();
- }
- }
-
-
- Filein = F;
- Filelineno = 1;
- Fileparse();
-
- if (F != stdin)
- fclose(F);
- Filein = stdin;
-}
static std::ostream &err() {
return std::cerr << "Parsing Line #" << Filelineno << ": ";
From brukman at cs.uiuc.edu Wed Jul 30 15:17:00 2003
From: brukman at cs.uiuc.edu (Misha Brukman)
Date: Wed Jul 30 15:17:00 2003
Subject: [llvm-commits] CVS: llvm/tools/bugpoint/ExecutionDriver.cpp
Message-ID: <200307302016.PAA24912@zion.cs.uiuc.edu>
Changes in directory llvm/tools/bugpoint:
ExecutionDriver.cpp updated: 1.11 -> 1.12
---
Log message:
* Moved InputArgv out of anonymous scope to be extern'd in another file.
* Added DEBUG() statements to print out parameters passed to executing programs
* Actually ADD parameters to a program running via the JIT (using vector)
---
Diffs of the changes:
Index: llvm/tools/bugpoint/ExecutionDriver.cpp
diff -u llvm/tools/bugpoint/ExecutionDriver.cpp:1.11 llvm/tools/bugpoint/ExecutionDriver.cpp:1.12
--- llvm/tools/bugpoint/ExecutionDriver.cpp:1.11 Wed Jul 30 12:59:23 2003
+++ llvm/tools/bugpoint/ExecutionDriver.cpp Wed Jul 30 15:15:44 2003
@@ -40,15 +40,15 @@
InputFile("input", cl::init("/dev/null"),
cl::desc("Filename to pipe in as stdin (default: /dev/null)"));
- // Anything specified after the --args option are taken as arguments to the
- // program being debugged.
- cl::list
- InputArgv("args", cl::Positional, cl::desc("..."),
- cl::ZeroOrMore);
-
enum FileType { AsmFile, CFile };
}
+// Anything specified after the --args option are taken as arguments to the
+// program being debugged.
+cl::list
+InputArgv("args", cl::Positional, cl::desc("..."),
+ cl::ZeroOrMore);
+
/// AbstractInterpreter Class - Subclasses of this class are used to execute
/// LLVM bytecode in a variety of ways. This abstract interface hides this
/// complexity behind a simple interface.
@@ -99,19 +99,24 @@
exit(1);
}
- std::vector Args;
- Args.push_back(LLIPath.c_str());
- Args.push_back("-abort-on-exception");
- Args.push_back("-quiet");
- Args.push_back("-force-interpreter=true");
- Args.push_back(Bytecode.c_str());
+ std::vector LLIArgs;
+ LLIArgs.push_back(LLIPath.c_str());
+ LLIArgs.push_back("-abort-on-exception");
+ LLIArgs.push_back("-quiet");
+ LLIArgs.push_back("-force-interpreter=true");
+ LLIArgs.push_back(Bytecode.c_str());
// Add optional parameters to the running program from Argv
for (unsigned i=0, e = InputArgv.size(); i != e; ++i)
- Args.push_back(InputArgv[i].c_str());
- Args.push_back(0);
+ LLIArgs.push_back(InputArgv[i].c_str());
+ LLIArgs.push_back(0);
std::cout << "";
- return RunProgramWithTimeout(LLIPath, &Args[0],
+ DEBUG(std::cerr << "About to run:\n\t";
+ for (unsigned i=0, e = LLIArgs.size(); i != e; ++i)
+ std::cerr << " " << LLIArgs[i];
+ std::cerr << "\n";
+ );
+ return RunProgramWithTimeout(LLIPath, &LLIArgs[0],
InputFile, OutputFile, OutputFile);
}
@@ -186,6 +191,11 @@
// Now that we have a binary, run it!
std::cout << "";
+ DEBUG(std::cerr << "About to run:\n\t";
+ for (unsigned i=0, e = ProgramArgs.size(); i != e; ++i)
+ std::cerr << " " << ProgramArgs[i];
+ std::cerr << "\n";
+ );
int ProgramResult = RunProgramWithTimeout(OutputBinary, &ProgramArgs[0],
InputFile, OutputFile, OutputFile);
std::cout << "\n";
@@ -348,24 +358,29 @@
int JIT::ExecuteProgram(const std::string &Bytecode,
const std::string &OutputFile,
const std::string &SharedLib) {
- const char* ArgsWithoutSO[] = {
- LLIPath.c_str(), "-quiet", "-force-interpreter=false",
- Bytecode.c_str(),
- 0
- };
-
- const char* ArgsWithSO[] = {
- LLIPath.c_str(), "-quiet", "-force-interpreter=false",
- "-load", SharedLib.c_str(),
- Bytecode.c_str(),
- 0
- };
-
- const char** JITArgs = SharedLib.empty() ? ArgsWithoutSO : ArgsWithSO;
+ // Construct a vector of parameters, incorporating those from the command-line
+ std::vector JITArgs;
+ JITArgs.push_back(LLIPath.c_str());
+ JITArgs.push_back("-quiet");
+ JITArgs.push_back("-force-interpreter=false");
+ if (!SharedLib.empty()) {
+ JITArgs.push_back("-load");
+ JITArgs.push_back(SharedLib.c_str());
+ }
+ JITArgs.push_back(Bytecode.c_str());
+ // Add optional parameters to the running program from Argv
+ for (unsigned i=0, e = InputArgv.size(); i != e; ++i)
+ JITArgs.push_back(InputArgv[i].c_str());
+ JITArgs.push_back(0);
- std::cout << "";
+ std::cout << "\n";
+ DEBUG(std::cerr << "About to run:\n\t";
+ for (unsigned i=0, e = JITArgs.size(); i != e; ++i)
+ std::cerr << " " << JITArgs[i];
+ std::cerr << "\n";
+ );
DEBUG(std::cerr << "\nSending output to " << OutputFile << "\n");
- return RunProgramWithTimeout(LLIPath, JITArgs,
+ return RunProgramWithTimeout(LLIPath, &JITArgs[0],
InputFile, OutputFile, OutputFile);
}
From brukman at cs.uiuc.edu Wed Jul 30 15:17:05 2003
From: brukman at cs.uiuc.edu (Misha Brukman)
Date: Wed Jul 30 15:17:05 2003
Subject: [llvm-commits] CVS: llvm/tools/bugpoint/CodeGeneratorBug.cpp ListReducer.h Miscompilation.cpp
Message-ID: <200307302016.PAA24903@zion.cs.uiuc.edu>
Changes in directory llvm/tools/bugpoint:
CodeGeneratorBug.cpp updated: 1.5 -> 1.6
ListReducer.h updated: 1.3 -> 1.4
Miscompilation.cpp updated: 1.10 -> 1.11
---
Log message:
CodeGeneratorBug.cpp:
* Temporarily externing InputArgv to print it out for the benefit of LLI command
needed to reproduce the result.
* Print out the list of functions currently being tested
* ListReducer now returns a bool if there was a failure, so test for it
ListReducer.h:
* Handle the case where there is no problem by returning true if failure is
found. Also correctly handles the case when there is only 1 pass/function.
Miscompilation.cpp:
* ListReducer now returns a bool if there was a failure, so test for it
---
Diffs of the changes:
Index: llvm/tools/bugpoint/CodeGeneratorBug.cpp
diff -u llvm/tools/bugpoint/CodeGeneratorBug.cpp:1.5 llvm/tools/bugpoint/CodeGeneratorBug.cpp:1.6
--- llvm/tools/bugpoint/CodeGeneratorBug.cpp:1.5 Tue Jul 29 11:02:28 2003
+++ llvm/tools/bugpoint/CodeGeneratorBug.cpp Wed Jul 30 15:15:56 2003
@@ -20,11 +20,14 @@
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Linker.h"
+#include "Support/CommandLine.h"
#include "Support/Statistic.h"
#include "Support/StringExtras.h"
#include
#include
+extern cl::list InputArgv;
+
class ReduceMisCodegenFunctions : public ListReducer {
BugDriver &BD;
public:
@@ -47,10 +50,9 @@
bool ReduceMisCodegenFunctions::TestFuncs(const std::vector &Funcs,
bool KeepFiles)
{
- DEBUG(std::cerr << "Test functions are:\n");
- for (std::vector::const_iterator I = Funcs.begin(),E = Funcs.end();
- I != E; ++I)
- DEBUG(std::cerr << "\t" << (*I)->getName() << "\n");
+ std::cout << "Testing functions: ";
+ BD.PrintFunctionList(Funcs);
+ std::cout << "\t";
// Clone the module for the two halves of the program we want.
Module *SafeModule = CloneModule(BD.Program);
@@ -150,7 +152,7 @@
// cast the result from the resolver to correctly-typed function
CastInst *castResolver =
new CastInst(resolve, PointerType::get(F->getFunctionType()),
- "", Inst);
+ "resolverCast", Inst);
// actually use the resolved function
Inst->replaceUsesOfWith(F, castResolver);
} else {
@@ -227,8 +229,12 @@
if (KeepFiles) {
std::cout << "You can reproduce the problem with the command line: \n"
<< (BD.isExecutingJIT() ? "lli" : "llc")
- << " -load " << SharedObject << " " << TestModuleBC
- << "\n";
+ << " -load " << SharedObject << " " << TestModuleBC;
+ for (unsigned i=0, e = InputArgv.size(); i != e; ++i)
+ std::cout << " " << InputArgv[i];
+ std::cout << "\n";
+ std::cout << "The shared object " << SharedObject << " was created from "
+ << SafeModuleBC << ", using `dis -c'.\n";
} else {
removeFile(TestModuleBC);
removeFile(SafeModuleBC);
@@ -346,7 +352,11 @@
DisambiguateGlobalSymbols(Program);
// Do the reduction...
- ReduceMisCodegenFunctions(*this).reduceList(MisCodegenFunctions);
+ if (!ReduceMisCodegenFunctions(*this).reduceList(MisCodegenFunctions)) {
+ std::cerr << "*** Execution matches reference output! No problem "
+ << "detected...\nbugpoint can't help you with your problem!\n";
+ return false;
+ }
std::cout << "\n*** The following functions are being miscompiled: ";
PrintFunctionList(MisCodegenFunctions);
Index: llvm/tools/bugpoint/ListReducer.h
diff -u llvm/tools/bugpoint/ListReducer.h:1.3 llvm/tools/bugpoint/ListReducer.h:1.4
--- llvm/tools/bugpoint/ListReducer.h:1.3 Thu Apr 24 22:16:33 2003
+++ llvm/tools/bugpoint/ListReducer.h Wed Jul 30 15:15:56 2003
@@ -30,7 +30,24 @@
// list while still maintaining the "test" property. This is the core of the
// "work" that bugpoint does.
//
- void reduceList(std::vector &TheList) {
+ bool reduceList(std::vector &TheList) {
+ std::vector empty;
+ switch (doTest(TheList, empty)) {
+ case KeepPrefix:
+ if (TheList.size() == 1) // we are done, it's the base case and it fails
+ return true;
+ else
+ break; // there's definitely an error, but we need to narrow it down
+
+ case KeepSuffix:
+ // cannot be reached!
+ std::cerr << "bugpoint ListReducer internal error: selected empty set.\n";
+ abort();
+
+ case NoFailure:
+ return false; // there is no failure with the full set of passes/funcs!
+ }
+
unsigned MidTop = TheList.size();
while (MidTop > 1) {
unsigned Mid = MidTop / 2;
@@ -80,6 +97,8 @@
}
}
}
+
+ return true; // there are some failure and we've narrowed them down
}
};
Index: llvm/tools/bugpoint/Miscompilation.cpp
diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.10 llvm/tools/bugpoint/Miscompilation.cpp:1.11
--- llvm/tools/bugpoint/Miscompilation.cpp:1.10 Thu Jul 24 13:17:43 2003
+++ llvm/tools/bugpoint/Miscompilation.cpp Wed Jul 30 15:15:56 2003
@@ -268,12 +268,8 @@
return false; // Problem found
}
- // Figure out which transformations miscompile the input program.
- unsigned OldSize = PassesToRun.size();
- ReduceMiscompilingPasses(*this).reduceList(PassesToRun);
-
// Make sure something was miscompiled...
- if (PassesToRun.size() == OldSize) {
+ if (!ReduceMiscompilingPasses(*this).reduceList(PassesToRun)) {
std::cerr << "*** Optimized program matches reference output! No problem "
<< "detected...\nbugpoint can't help you with your problem!\n";
return false;
From lattner at cs.uiuc.edu Wed Jul 30 15:56:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 15:56:01 2003
Subject: [llvm-commits] CVS: llvm/test/Regression/TableGen/Include.inc Include.td
Message-ID: <200307302055.PAA20352@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Regression/TableGen:
Include.inc added (r1.1)
Include.td added (r1.1)
---
Log message:
Add test of file inclusion capability for bugpoint
---
Diffs of the changes:
Index: llvm/test/Regression/TableGen/Include.inc
diff -c /dev/null llvm/test/Regression/TableGen/Include.inc:1.1
*** /dev/null Wed Jul 30 15:55:47 2003
--- llvm/test/Regression/TableGen/Include.inc Wed Jul 30 15:55:37 2003
***************
*** 0 ****
--- 1,4 ----
+ // This is used by the Include.td test
+ def InInclude;
+
+
Index: llvm/test/Regression/TableGen/Include.td
diff -c /dev/null llvm/test/Regression/TableGen/Include.td:1.1
*** /dev/null Wed Jul 30 15:55:47 2003
--- llvm/test/Regression/TableGen/Include.td Wed Jul 30 15:55:37 2003
***************
*** 0 ****
--- 1,7 ----
+
+ def BeforeInclude;
+
+ include "Include.inc"
+
+ def AfterInclude;
+
From lattner at cs.uiuc.edu Wed Jul 30 15:57:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 15:57:01 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileLexer.l FileParser.y
Message-ID: <200307302056.PAA20414@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
FileLexer.l updated: 1.3 -> 1.4
FileParser.y updated: 1.12 -> 1.13
---
Log message:
Move err() to the lexer, implement file inclusion capabilities directly in tblgen
---
Diffs of the changes:
Index: llvm/utils/TableGen/FileLexer.l
diff -u llvm/utils/TableGen/FileLexer.l:1.3 llvm/utils/TableGen/FileLexer.l:1.4
--- llvm/utils/TableGen/FileLexer.l:1.3 Wed Jul 30 14:55:10 2003
+++ llvm/utils/TableGen/FileLexer.l Wed Jul 30 15:56:47 2003
@@ -8,7 +8,6 @@
%option nostdinit
%option never-interactive
%option batch
-%option noyywrap
%option nodefault
%option 8bit
%option outfile="Lexer.cpp"
@@ -32,6 +31,32 @@
static int CommentDepth = 0;
+struct IncludeRec {
+ std::string Filename;
+ FILE *File;
+ unsigned LineNo;
+ YY_BUFFER_STATE Buffer;
+
+ IncludeRec(const std::string &FN, FILE *F)
+ : Filename(FN), File(F), LineNo(0){
+ }
+};
+
+static std::vector IncludeStack;
+
+
+std::ostream &err() {
+ if (IncludeStack.empty())
+ return std::cerr << "At end of input: ";
+
+ for (unsigned i = 0, e = IncludeStack.size()-1; i != e; ++i)
+ std::cerr << "IncFrom " << IncludeStack[i].Filename << ":"
+ << IncludeStack[i].LineNo << ":\n";
+ return std::cerr << "Parsing " << IncludeStack.back().Filename << ":"
+ << Filelineno << ": ";
+}
+
+
int Fileparse();
void ParseFile(const std::string &Filename) {
@@ -43,17 +68,68 @@
std::cerr << "Could not open input file '" + Filename + "'!\n";
abort();
}
+ IncludeStack.push_back(IncludeRec(Filename, F));
+ } else {
+ IncludeStack.push_back(IncludeRec("", stdin));
}
Filein = F;
Filelineno = 1;
Fileparse();
-
- if (F != stdin)
- fclose(F);
Filein = stdin;
}
+// HandleInclude - This function is called when an include directive is
+// encountered in the input stream...
+static void HandleInclude(const char *Buffer) {
+ unsigned Length = yyleng;
+ assert(Buffer[Length-1] == '"');
+ Buffer += strlen("include ");
+ Length -= strlen("include ");
+ while (*Buffer != '"') {
+ ++Buffer;
+ --Length;
+ }
+ assert(Length >= 2 && "Double quotes not found?");
+ std::string Filename(Buffer+1, Buffer+Length-1);
+ //std::cerr << "Filename = '" << Filename << "'\n";
+
+ // Save the line number and lex buffer of the includer...
+ IncludeStack.back().LineNo = Filelineno;
+ IncludeStack.back().Buffer = YY_CURRENT_BUFFER;
+
+ // Open the new input file...
+ yyin = fopen(Filename.c_str(), "r");
+ if (yyin == 0) {
+ err() << "Could not find include file '" << Filename << "'!\n";
+ abort();
+ }
+
+ // Add the file to our include stack...
+ IncludeStack.push_back(IncludeRec(Filename, yyin));
+ Filelineno = 1; // Reset line numbering...
+ //yyrestart(yyin); // Start lexing the new file...
+
+ yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
+}
+
+
+// yywrap - This is called when the lexer runs out of input in one of the files.
+// Switch back to an includer if an includee has run out of input.
+//
+extern "C"
+int yywrap() {
+ if (IncludeStack.back().File != stdin)
+ fclose(IncludeStack.back().File);
+ IncludeStack.pop_back();
+ if (IncludeStack.empty()) return 1; // Top-level file is done.
+
+ // Otherwise, we need to switch back to a file which included the current one.
+ Filelineno = IncludeStack.back().LineNo; // Restore current line number
+ yy_switch_to_buffer(IncludeStack.back().Buffer);
+ return 0;
+}
+
%}
Comment \/\/.*
@@ -61,11 +137,15 @@
Identifier [a-zA-Z_][0-9a-zA-Z_]*
Integer [-+]?[0-9]+|0x[0-9a-fA-F]+|0b[01]+
StringVal \"[^"]*\"
+IncludeStr include[ \t\n]+\"[^"]*\"
%%
{Comment} { /* Ignore comments */ }
+{IncludeStr} { HandleInclude(yytext); }
+
+
int { return INT; }
bit { return BIT; }
bits { return BITS; }
@@ -87,7 +167,6 @@
{Integer} { Filelval.IntVal = ParseInt(Filetext); return INTVAL; }
[ \t\n]+ { /* Ignore whitespace */ }
-. { return Filetext[0]; }
"/*" { BEGIN(comment); CommentDepth++; }
@@ -96,6 +175,8 @@
"/*" { ++CommentDepth; }
"/"+[^*]* /* eat up /'s not followed by *'s */
"*"+"/" { if (!--CommentDepth) { BEGIN(INITIAL); } }
-<> { fprintf(stderr, "Unterminated comment!\n"); abort(); }
+<> { err() << "Unterminated comment!\n"; abort(); }
+
+. { return Filetext[0]; }
%%
Index: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.12 llvm/utils/TableGen/FileParser.y:1.13
--- llvm/utils/TableGen/FileParser.y:1.12 Wed Jul 30 14:55:10 2003
+++ llvm/utils/TableGen/FileParser.y Wed Jul 30 15:56:47 2003
@@ -21,9 +21,7 @@
static std::vector*>,
Init*> > SetStack;
-static std::ostream &err() {
- return std::cerr << "Parsing Line #" << Filelineno << ": ";
-}
+extern std::ostream &err();
static void addValue(const RecordVal &RV) {
if (CurRec->getValue(RV.getName())) {
From lattner at cs.uiuc.edu Wed Jul 30 16:01:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 16:01:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/Makefile SparcV9.td
Message-ID: <200307302100.QAA20643@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Target/Sparc:
Makefile updated: 1.26 -> 1.27
SparcV9.td updated: 1.25 -> 1.26
---
Log message:
We no longer need to preprocess SparcV9.td before sending it through tablegen
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/Makefile
diff -u llvm/lib/Target/Sparc/Makefile:1.26 llvm/lib/Target/Sparc/Makefile:1.27
--- llvm/lib/Target/Sparc/Makefile:1.26 Wed Jul 30 00:49:17 2003
+++ llvm/lib/Target/Sparc/Makefile Wed Jul 30 16:00:37 2003
@@ -50,7 +50,7 @@
$(TARGET_NAME)CodeEmitter.inc.tmp: $(TABLEGEN_FILES) $(TBLGEN)
@${ECHO} "TableGen-erating " $(TARGET_NAME)
- $(CC) -E -xc -P $(TARGET_NAME).td | $(TBLGEN) -gen-emitter -o $@
+ $(TBLGEN) $(TARGET_NAME).td -gen-emitter -o $@
$(TARGET_NAME)CodeEmitter.inc: $(TARGET_NAME)CodeEmitter.inc.tmp
$(VERB) # Only copy over the real .inc file if it has changed!
Index: llvm/lib/Target/Sparc/SparcV9.td
diff -u llvm/lib/Target/Sparc/SparcV9.td:1.25 llvm/lib/Target/Sparc/SparcV9.td:1.26
--- llvm/lib/Target/Sparc/SparcV9.td:1.25 Tue Jul 29 16:21:20 2003
+++ llvm/lib/Target/Sparc/SparcV9.td Wed Jul 30 16:00:37 2003
@@ -2,9 +2,9 @@
// vim:ft=cpp
//===----------------------------------------------------------------------===//
-#include "../Target.td"
+include "../Target.td"
-#include "SparcV9_Reg.td"
+include "SparcV9_Reg.td"
//===----------------------------------------------------------------------===//
// Instructions
@@ -24,9 +24,9 @@
bit isPrivileged = 0; // Is this a privileged instruction?
}
-#include "SparcV9_F2.td"
-#include "SparcV9_F3.td"
-#include "SparcV9_F4.td"
+include "SparcV9_F2.td"
+include "SparcV9_F3.td"
+include "SparcV9_F4.td"
//===----------------------------------------------------------------------===//
// Instruction list...
@@ -54,7 +54,7 @@
// Section A.4: Branch on Floating-Point Condition Codes (FBfcc) p140
// The following deprecated instructions don't seem to play nice on Sparc
-#if 0
+/*
set isDeprecated = 1 in {
set op2 = 0b110 in {
def FBA : F2_2<0b1000, "fba">; // Branch always
@@ -75,7 +75,7 @@
def FBO : F2_2<0b1111, "fbo">; // Branch on ordered
}
}
-#endif
+*/
// We now make these same opcodes represent the FBPfcc instructions
set op2 = 0b101 in {
@@ -99,7 +99,7 @@
// Section A.5: Branch on FP condition codes with prediction - p143
// Not used in the Sparc backend (directly)
-#if 0
+/*
set op2 = 0b101 in {
def FBPA : F2_3<0b1000, "fba">; // Branch always
def FBPN : F2_3<0b0000, "fbn">; // Branch never
@@ -118,10 +118,10 @@
def FBPULE : F2_3<0b1110, "fbule">; // Branch unord or < or ==
def FBPO : F2_3<0b1111, "fbo">; // Branch on ordered
}
-#endif
+*/
// Section A.6: Branch on Integer condition codes (Bicc) - p146
-#if 0
+/*
set isDeprecated = 1 in {
set op2 = 0b010 in {
def BA : F2_2<0b1000, "ba">; // Branch always
@@ -142,7 +142,7 @@
def BVS : F2_2<0b0111, "bvs">; // Branch on overflow set
}
}
-#endif
+*/
// Using the format of A.7 instructions...
set op2 = 0b001 in {
@@ -168,7 +168,7 @@
// Section A.7: Branch on integer condition codes with prediction - p148
// Not used in the Sparc backend
-#if 0
+/*
set op2 = 0b001 in {
def BPA : F2_3<0b1000, "bpa">; // Branch always
def BPN : F2_3<0b0000, "bpn">; // Branch never
@@ -187,7 +187,7 @@
def BPVC : F2_3<0b1111, "bpvc">; // Branch on overflow clear
def BPVS : F2_3<0b0111, "bpvs">; // Branch on overflow set
}
-#endif
+*/
// Section A.8: CALL - p151, the only Format #1 instruction
def CALL : InstV9 {
@@ -204,7 +204,7 @@
// Section A.10: Divide (64-bit / 32-bit) - p178
// Not used in the Sparc backend
-#if 0
+/*
set isDeprecated = 1 in {
def UDIVr : F3_1<2, 0b001110, "udiv">; // udiv r, r, r
def UDIVi : F3_2<2, 0b001110, "udiv">; // udiv r, r, i
@@ -215,16 +215,16 @@
def SDIVCCr : F3_1<2, 0b011111, "sdivcc">; // sdivcc r, r, r
def SDIVCCi : F3_2<2, 0b011111, "sdivcc">; // sdivcc r, r, i
}
-#endif
+*/
// Section A.11: DONE and RETRY - p181
// Not used in the Sparc backend
-#if 0
+/*
set isPrivileged = 1 in {
def DONE : F3_18<0, "done">; // done
def RETRY : F3_18<1, "retry">; // retry
}
-#endif
+*/
// Section A.12: Floating-Point Add and Subtract - p156
def FADDS : F3_16<2, 0b110100, 0x41, "fadds">; // fadds frs1, frs2, frd
@@ -239,11 +239,11 @@
def FCMPD : F3_15<2, 0b110101, 0b001010010, "fcmpd">; // fcmpd %fcc, r1, r2
def FCMPQ : F3_15<2, 0b110101, 0b001010011, "fcmpq">; // fcmpq %fcc, r1, r2
// Currently unused in the Sparc backend
-#if 0
+/*
def FCMPES : F3_15<2, 0b110101, 0b001010101, "fcmpes">; // fcmpes %fcc, r1, r2
def FCMPED : F3_15<2, 0b110101, 0b001010110, "fcmped">; // fcmped %fcc, r1, r2
def FCMPEQ : F3_15<2, 0b110101, 0b001010111, "fcmpeq">; // fcmpeq %fcc, r1, r2
-#endif
+*/
// Section A.14: Convert floating-point to integer - p161
def FSTOX : F3_14<2, 0b110100, 0b010000001, "fstox">; // fstox rs2, rd
@@ -348,12 +348,12 @@
def LDUWi : F3_2<3, 0b000000, "lduw">; // lduw [rs1+imm], rd
def LDXr : F3_1<3, 0b001011, "ldx">; // ldx [rs1+rs2], rd
def LDXi : F3_2<3, 0b001011, "ldx">; // ldx [rs1+imm], rd
-#if 0
+/*
set isDeprecated = 1 in {
def LDDr : F3_1<3, 0b000011, "ldd">; // ldd [rs1+rs2], rd
def LDDi : F3_2<3, 0b000011, "ldd">; // ldd [rs1+imm], rd
}
-#endif
+*/
// Section A.31: Logical operations
def ANDr : F3_1<2, 0b000001, "and">; // and rs1, rs2, rd
@@ -614,7 +614,7 @@
// Section A.38: Multiply (32-bit) - p200
// Not used in the Sparc backend
-#if 0
+/*
set Inst{13} = 0 in {
def UMULr : F3_1<2, 0b001010, "umul">; // umul r, r, r
def SMULr : F3_1<2, 0b001011, "smul">; // smul r, r, r
@@ -627,7 +627,7 @@
def UMULCCi : F3_1<2, 0b011010, "umulcc">; // umulcc r, i, r
def SMULCCi : F3_1<2, 0b011011, "smulcc">; // smulcc r, i, r
}
-#endif
+*/
// Section A.39: Multiply Step - p202
// Not currently used in the Sparc backend
@@ -679,7 +679,7 @@
// Section A.49: Shift - p221
// Not currently used in the Sparc backend
-#if 0
+/*
uses 5 least significant bits of rs2
set x = 0 in {
def SLLr5 : F3_11<2, 0b100101, "sll">; // sll r, r, r
@@ -689,7 +689,7 @@
def SRLXr5 : F3_11<2, 0b100110, "srlx">; // srlx r, r, r
def SRAXr5 : F3_11<2, 0b100111, "srax">; // srax r, r, r
}
-#endif
+*/
// uses 6 least significant bits of rs2
set x = 0 in {
@@ -724,20 +724,20 @@
def STDFi : F3_2rd<3, 0b100111, "std">; // std r, [r+i]
// Not currently used in the Sparc backend
-#if 0
+/*
def STQFr : F3_1rd<3, 0b100110, "stq">; // stq r, [r+r]
def STQFi : F3_2rd<3, 0b100110, "stq">; // stq r, [r+i]
-#endif
+*/
// FIXME: An encoding needs to be chosen here, because STFSRx expect rd=0,
// while STXFSRx expect rd=1, but assembly syntax dictates %fsr as first arg.
// These are being disabled because they aren't used in the Sparc backend.
-#if 0
+/*
set isDeprecated = 1 in {
def STFSRr : F3_1<3, 0b100101, "st">; // st %fsr, [r+r]
def STFSRi : F3_2<3, 0b100101, "st">; // st %fsr, [r+i]
}
-#endif
+*/
def STXFSRr : F3_1<3, 0b100101, "stx">; // stx %fsr, [r+r]
def STXFSRi : F3_2<3, 0b100101, "stx">; // stx %fsr, [r+i]
From brukman at cs.uiuc.edu Wed Jul 30 16:46:02 2003
From: brukman at cs.uiuc.edu (Misha Brukman)
Date: Wed Jul 30 16:46:02 2003
Subject: [llvm-commits] CVS: llvm/tools/bugpoint/CodeGeneratorBug.cpp
Message-ID: <200307302145.QAA28673@zion.cs.uiuc.edu>
Changes in directory llvm/tools/bugpoint:
CodeGeneratorBug.cpp updated: 1.6 -> 1.7
---
Log message:
Ignore intrinsic functions -- don't mangle their names or rewrite calls to them.
---
Diffs of the changes:
Index: llvm/tools/bugpoint/CodeGeneratorBug.cpp
diff -u llvm/tools/bugpoint/CodeGeneratorBug.cpp:1.6 llvm/tools/bugpoint/CodeGeneratorBug.cpp:1.7
--- llvm/tools/bugpoint/CodeGeneratorBug.cpp:1.6 Wed Jul 30 15:15:56 2003
+++ llvm/tools/bugpoint/CodeGeneratorBug.cpp Wed Jul 30 16:45:20 2003
@@ -113,7 +113,8 @@
// Use the function we just added to get addresses of functions we need
// Iterate over the global declarations in the Safe module
for (Module::iterator F=SafeModule->begin(),E=SafeModule->end(); F!=E; ++F){
- if (F->isExternal() && !F->use_empty() && &(*F) != resolverFunc) {
+ if (F->isExternal() && !F->use_empty() && &(*F) != resolverFunc &&
+ F->getIntrinsicID() == 0 /* ignore intrinsics */) {
// If it has a non-zero use list,
// 1. Add a string constant with its name to the global file
// The correct type is `const [ NUM x sbyte ]' where NUM is length of
@@ -257,6 +258,10 @@
if (externalOnly && !V.isExternal()) return;
// If we're already processed this symbol, don't add it again
if (Symbols.count(&V) != 0) return;
+ // Ignore intrinsic functions
+ if (Function *F = dyn_cast(&V))
+ if (F->getIntrinsicID() != 0)
+ return;
std::string SymName = V.getName();
From lattner at cs.uiuc.edu Wed Jul 30 16:48:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 16:48:01 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileLexer.l FileParser.y Record.h
Message-ID: <200307302147.QAA21714@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
FileLexer.l updated: 1.4 -> 1.5
FileParser.y updated: 1.13 -> 1.14
Record.h updated: 1.14 -> 1.15
---
Log message:
Initial support for the 'code' type.
---
Diffs of the changes:
Index: llvm/utils/TableGen/FileLexer.l
diff -u llvm/utils/TableGen/FileLexer.l:1.4 llvm/utils/TableGen/FileLexer.l:1.5
--- llvm/utils/TableGen/FileLexer.l:1.4 Wed Jul 30 15:56:47 2003
+++ llvm/utils/TableGen/FileLexer.l Wed Jul 30 16:47:42 2003
@@ -151,6 +151,7 @@
bits { return BITS; }
string { return STRING; }
list { return LIST; }
+code { return CODE; }
class { return CLASS; }
def { return DEF; }
Index: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.13 llvm/utils/TableGen/FileParser.y:1.14
--- llvm/utils/TableGen/FileParser.y:1.13 Wed Jul 30 15:56:47 2003
+++ llvm/utils/TableGen/FileParser.y Wed Jul 30 16:47:42 2003
@@ -153,7 +153,7 @@
std::vector *SubClassList;
};
-%token INT BIT STRING BITS LIST CLASS DEF FIELD SET IN
+%token INT BIT STRING BITS LIST CODE CLASS DEF FIELD SET IN
%token INTVAL
%token ID STRVAL
@@ -202,6 +202,8 @@
$$ = new IntRecTy();
} | LIST '<' ClassID '>' { // list type
$$ = new ListRecTy($3);
+ } | CODE { // code type
+ $$ = new CodeRecTy();
} | ClassID { // Record Type
$$ = new RecordRecTy($1);
};
Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.14 llvm/utils/TableGen/Record.h:1.15
--- llvm/utils/TableGen/Record.h:1.14 Tue Jul 29 23:56:05 2003
+++ llvm/utils/TableGen/Record.h Wed Jul 30 16:47:42 2003
@@ -131,6 +131,15 @@
void print(std::ostream &OS) const;
};
+/// CodeRecTy - 'code' - Represent an code fragment, function or method.
+///
+struct CodeRecTy : public RecTy {
+ Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
+
+ void print(std::ostream &OS) const { OS << "code"; }
+};
+
+
/// RecordRecTy - '' - Represent an instance of a class, such as:
/// (R32 X = EAX).
///
From lattner at cs.uiuc.edu Wed Jul 30 17:17:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 17:17:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/Target.td
Message-ID: <200307302216.RAA00306@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Target:
Target.td updated: 1.5 -> 1.6
---
Log message:
Add comments
Make the register classes optionally take code fragments for allocation_order_*
---
Diffs of the changes:
Index: llvm/lib/Target/Target.td
diff -u llvm/lib/Target/Target.td:1.5 llvm/lib/Target/Target.td:1.6
--- llvm/lib/Target/Target.td:1.5 Wed Jul 30 00:50:12 2003
+++ llvm/lib/Target/Target.td Wed Jul 30 17:16:41 2003
@@ -10,7 +10,7 @@
//
// Value types - These values correspond to the register types defined in the
// ValueTypes.h file.
-
+//
class ValueType { string Namespace = "MVT"; }
def i1 : ValueType; // One bit boolean value
@@ -53,9 +53,27 @@
// registers by register allocators.
//
class RegisterClass regList> {
+ // RegType - Specify the ValueType of the registers in this register class.
+ // Note that all registers in a register class must have the same ValueType.
+ //
ValueType RegType = regType;
+
+ // Alignment - Specify the alignment required of the registers when they are
+ // stored or loaded to memory.
+ //
int Alignment = alignment;
+
+ // MemberList - Specify which registers are in this class. If the
+ // allocation_order_* method are not specified, this also defines the order of
+ // allocation used by the register allocator.
+ //
list MemberList = regList;
+
+ // allocation_order_* - These methods define the order that the registers
+ // should be allocated. See the MRegister.h file for more information.
+ //
+ code allocation_order_begin;
+ code allocation_order_end;
}
From lattner at cs.uiuc.edu Wed Jul 30 17:17:05 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 17:17:05 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileLexer.l FileParser.y Record.h
Message-ID: <200307302216.RAA32763@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
FileLexer.l updated: 1.5 -> 1.6
FileParser.y updated: 1.14 -> 1.15
Record.h updated: 1.15 -> 1.16
---
Log message:
Add support for code fragments
---
Diffs of the changes:
Index: llvm/utils/TableGen/FileLexer.l
diff -u llvm/utils/TableGen/FileLexer.l:1.5 llvm/utils/TableGen/FileLexer.l:1.6
--- llvm/utils/TableGen/FileLexer.l:1.5 Wed Jul 30 16:47:42 2003
+++ llvm/utils/TableGen/FileLexer.l Wed Jul 30 17:15:58 2003
@@ -132,19 +132,21 @@
%}
-Comment \/\/.*
+Comment \/\/.*
-Identifier [a-zA-Z_][0-9a-zA-Z_]*
-Integer [-+]?[0-9]+|0x[0-9a-fA-F]+|0b[01]+
-StringVal \"[^"]*\"
-IncludeStr include[ \t\n]+\"[^"]*\"
+Identifier [a-zA-Z_][0-9a-zA-Z_]*
+Integer [-+]?[0-9]+|0x[0-9a-fA-F]+|0b[01]+
+CodeFragment \[\{([^}]+|\}[^\]])*\}\]
+StringVal \"[^"]*\"
+IncludeStr include[ \t\n]+\"[^"]*\"
%%
{Comment} { /* Ignore comments */ }
{IncludeStr} { HandleInclude(yytext); }
-
+{CodeFragment} { Filelval.StrVal = new std::string(yytext+2, yytext+yyleng-2);
+ return CODEFRAGMENT; }
int { return INT; }
bit { return BIT; }
Index: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.14 llvm/utils/TableGen/FileParser.y:1.15
--- llvm/utils/TableGen/FileParser.y:1.14 Wed Jul 30 16:47:42 2003
+++ llvm/utils/TableGen/FileParser.y Wed Jul 30 17:15:58 2003
@@ -155,7 +155,7 @@
%token INT BIT STRING BITS LIST CODE CLASS DEF FIELD SET IN
%token INTVAL
-%token ID STRVAL
+%token ID STRVAL CODEFRAGMENT
%type Type
%type DefList DefListNE
@@ -216,6 +216,9 @@
$$ = new IntInit($1);
} | STRVAL {
$$ = new StringInit(*$1);
+ delete $1;
+ } | CODEFRAGMENT {
+ $$ = new CodeInit(*$1);
delete $1;
} | '?' {
$$ = new UnsetInit();
Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.15 llvm/utils/TableGen/Record.h:1.16
--- llvm/utils/TableGen/Record.h:1.15 Wed Jul 30 16:47:42 2003
+++ llvm/utils/TableGen/Record.h Wed Jul 30 17:15:58 2003
@@ -18,6 +18,7 @@
class BitsInit;
class IntInit;
class StringInit;
+class CodeInit;
class ListInit;
class DefInit;
class TypedInit;
@@ -39,6 +40,7 @@
virtual Init *convertValue( IntInit *II) { return 0; }
virtual Init *convertValue(StringInit *SI) { return 0; }
virtual Init *convertValue( ListInit *LI) { return 0; }
+ virtual Init *convertValue( CodeInit *CI) { return 0; }
virtual Init *convertValue(VarBitInit *VB) { return 0; }
virtual Init *convertValue( DefInit *DI) { return 0; }
virtual Init *convertValue( TypedInit *TI) { return 0; }
@@ -135,6 +137,7 @@
///
struct CodeRecTy : public RecTy {
Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
+ Init *convertValue( CodeInit *CI) { return (Init*)CI; }
void print(std::ostream &OS) const { OS << "code"; }
};
@@ -319,6 +322,20 @@
}
virtual void print(std::ostream &OS) const { OS << "\"" << Value << "\""; }
+};
+
+/// CodeInit - "[{...}]" - Represent a code fragment.
+///
+class CodeInit : public Init {
+ std::string Value;
+public:
+ CodeInit(const std::string &V) : Value(V) {}
+
+ virtual Init *convertInitializerTo(RecTy *Ty) {
+ return Ty->convertValue(this);
+ }
+
+ virtual void print(std::ostream &OS) const { OS << "[{" << Value << "}]"; }
};
/// ListInit - [AL, AH, CL] - Represent a list of defs
From tbrethou at niobe.cs.uiuc.edu Wed Jul 30 23:07:01 2003
From: tbrethou at niobe.cs.uiuc.edu (Tanya Brethour)
Date: Wed Jul 30 23:07:01 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/Instruction.h
Message-ID: <200307310406.h6V461g29267@niobe.cs.uiuc.edu>
Changes in directory llvm/include/llvm:
Instruction.h updated: 1.43 -> 1.44
---
Log message:
Added function to determine if an Instruction may trap.
---
Diffs of the changes:
Index: llvm/include/llvm/Instruction.h
diff -u llvm/include/llvm/Instruction.h:1.43 llvm/include/llvm/Instruction.h:1.44
--- llvm/include/llvm/Instruction.h:1.43 Mon Jul 28 11:53:28 2003
+++ llvm/include/llvm/Instruction.h Wed Jul 30 23:05:50 2003
@@ -97,7 +97,13 @@
bool isCommutative() const { return isCommutative(getOpcode()); }
static bool isCommutative(unsigned op);
-
+ /// isTrappingInstruction - Return true if the instruction may trap.
+ ///
+ bool isTrappingInstruction() const {
+ return isTrappingInstruction(getOpcode());
+ }
+ static bool isTrappingInstruction(unsigned op);
+
virtual void print(std::ostream &OS) const;
/// Methods for support type inquiry through isa, cast, and dyn_cast:
From tbrethou at niobe.cs.uiuc.edu Wed Jul 30 23:07:05 2003
From: tbrethou at niobe.cs.uiuc.edu (Tanya Brethour)
Date: Wed Jul 30 23:07:05 2003
Subject: [llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp
Message-ID: <200307310406.h6V46GD29273@niobe.cs.uiuc.edu>
Changes in directory llvm/lib/VMCore:
Instruction.cpp updated: 1.22 -> 1.23
---
Log message:
Added function to determine if an Instruction may trap.
---
Diffs of the changes:
Index: llvm/lib/VMCore/Instruction.cpp
diff -u llvm/lib/VMCore/Instruction.cpp:1.22 llvm/lib/VMCore/Instruction.cpp:1.23
--- llvm/lib/VMCore/Instruction.cpp:1.22 Wed May 7 21:44:12 2003
+++ llvm/lib/VMCore/Instruction.cpp Wed Jul 30 23:05:36 2003
@@ -137,3 +137,20 @@
return false;
}
}
+
+
+/// isTrappingInstruction - Return true if the instruction may trap.
+///
+bool Instruction::isTrappingInstruction(unsigned op) {
+ switch(op) {
+ case Div:
+ case Rem:
+ case Load:
+ case Store:
+ case Call:
+ case Invoke:
+ return true;
+ default:
+ return false;
+ }
+}
From lattner at cs.uiuc.edu Wed Jul 30 23:33:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 23:33:01 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/CodeEmitterGen.h
Message-ID: <200307310432.XAA01846@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
CodeEmitterGen.h updated: 1.3 -> 1.4
---
Log message:
Tighten up interface
---
Diffs of the changes:
Index: llvm/utils/TableGen/CodeEmitterGen.h
diff -u llvm/utils/TableGen/CodeEmitterGen.h:1.3 llvm/utils/TableGen/CodeEmitterGen.h:1.4
--- llvm/utils/TableGen/CodeEmitterGen.h:1.3 Tue Jul 29 18:00:08 2003
+++ llvm/utils/TableGen/CodeEmitterGen.h Wed Jul 30 23:32:37 2003
@@ -1,5 +1,6 @@
//===- CodeEmitterGen.h - Code Emitter Generator ----------------*- C++ -*-===//
//
+// FIXME: document
//
//===----------------------------------------------------------------------===//
@@ -7,15 +8,14 @@
#define CODEMITTERGEN_H
#include "Record.h"
-#include
-struct CodeEmitterGen {
+class CodeEmitterGen {
RecordKeeper &Records;
-
public:
CodeEmitterGen(RecordKeeper &R) : Records(R) {}
int createEmitter(std::ostream &o);
+private:
void emitMachineOpEmitter(std::ostream &o, const std::string &Namespace);
void emitGetValueBit(std::ostream &o, const std::string &Namespace);
};
From lattner at cs.uiuc.edu Wed Jul 30 23:39:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 23:39:01 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/CodeEmitterGen.cpp CodeEmitterGen.h TableGen.cpp
Message-ID: <200307310438.XAA02641@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
CodeEmitterGen.cpp updated: 1.14 -> 1.15
CodeEmitterGen.h updated: 1.4 -> 1.5
TableGen.cpp updated: 1.9 -> 1.10
---
Log message:
Rename createEmitter to run because eventually all tablegen backends will
be subclasses of a common interface.
---
Diffs of the changes:
Index: llvm/utils/TableGen/CodeEmitterGen.cpp
diff -u llvm/utils/TableGen/CodeEmitterGen.cpp:1.14 llvm/utils/TableGen/CodeEmitterGen.cpp:1.15
--- llvm/utils/TableGen/CodeEmitterGen.cpp:1.14 Tue Jul 29 18:00:08 2003
+++ llvm/utils/TableGen/CodeEmitterGen.cpp Wed Jul 30 23:38:26 2003
@@ -2,7 +2,7 @@
#include "Record.h"
#include "CodeEmitterGen.h"
-int CodeEmitterGen::createEmitter(std::ostream &o) {
+bool CodeEmitterGen::run(std::ostream &o) {
std::vector Insts;
const std::map &Defs = Records.getDefs();
@@ -33,7 +33,7 @@
const RecordVal *InstVal = R->getValue("Inst");
if (!InstVal) {
std::cerr << "No 'Inst' record found in target description file!\n";
- return 1;
+ return true;
}
Init *InitVal = InstVal->getValue();
@@ -229,5 +229,5 @@
<< " }\n"
<< " return Value;\n"
<< "}\n";
- return 0;
+ return false;
}
Index: llvm/utils/TableGen/CodeEmitterGen.h
diff -u llvm/utils/TableGen/CodeEmitterGen.h:1.4 llvm/utils/TableGen/CodeEmitterGen.h:1.5
--- llvm/utils/TableGen/CodeEmitterGen.h:1.4 Wed Jul 30 23:32:37 2003
+++ llvm/utils/TableGen/CodeEmitterGen.h Wed Jul 30 23:38:26 2003
@@ -14,7 +14,8 @@
public:
CodeEmitterGen(RecordKeeper &R) : Records(R) {}
- int createEmitter(std::ostream &o);
+ // run - Output the code emitter, returning true on failure.
+ bool run(std::ostream &o);
private:
void emitMachineOpEmitter(std::ostream &o, const std::string &Namespace);
void emitGetValueBit(std::ostream &o, const std::string &Namespace);
Index: llvm/utils/TableGen/TableGen.cpp
diff -u llvm/utils/TableGen/TableGen.cpp:1.9 llvm/utils/TableGen/TableGen.cpp:1.10
--- llvm/utils/TableGen/TableGen.cpp:1.9 Wed Jul 30 14:48:02 2003
+++ llvm/utils/TableGen/TableGen.cpp Wed Jul 30 23:38:26 2003
@@ -402,7 +402,7 @@
switch (Action) {
case Parse: ParseMachineCode(); break;
case GenEmitter:
- ErrorCode = CodeEmitterGen(Records).createEmitter(*Out);
+ ErrorCode = CodeEmitterGen(Records).run(*Out);
break;
case PrintRecords:
*Out << Records; // No argument, dump all contents
From lattner at cs.uiuc.edu Wed Jul 30 23:39:05 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 23:39:05 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/Record.h
Message-ID: <200307310438.XAA02646@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
Record.h updated: 1.16 -> 1.17
---
Log message:
Add file comment
---
Diffs of the changes:
Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.16 llvm/utils/TableGen/Record.h:1.17
--- llvm/utils/TableGen/Record.h:1.16 Wed Jul 30 17:15:58 2003
+++ llvm/utils/TableGen/Record.h Wed Jul 30 23:37:57 2003
@@ -1,5 +1,7 @@
//===- Record.h - Classes to represent Table Records ------------*- C++ -*-===//
//
+// This file defines the main TableGen data structures, including the TableGen
+// types, values, and high-level data structures.
//
//===----------------------------------------------------------------------===//
From lattner at cs.uiuc.edu Wed Jul 30 23:44:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Jul 30 23:44:01 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/CodeEmitterGen.cpp CodeEmitterGen.h
Message-ID: <200307310443.XAA03306@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
CodeEmitterGen.cpp updated: 1.15 -> 1.16
CodeEmitterGen.h updated: 1.5 -> 1.6
---
Log message:
More minor cleanups of the interface
---
Diffs of the changes:
Index: llvm/utils/TableGen/CodeEmitterGen.cpp
diff -u llvm/utils/TableGen/CodeEmitterGen.cpp:1.15 llvm/utils/TableGen/CodeEmitterGen.cpp:1.16
--- llvm/utils/TableGen/CodeEmitterGen.cpp:1.15 Wed Jul 30 23:38:26 2003
+++ llvm/utils/TableGen/CodeEmitterGen.cpp Wed Jul 30 23:43:49 2003
@@ -1,6 +1,12 @@
-#include "Support/Statistic.h"
-#include "Record.h"
+//===- CodeEmitterGen.cpp - Code Emitter Generator ------------------------===//
+//
+// FIXME: Document.
+//
+//===----------------------------------------------------------------------===//
+
#include "CodeEmitterGen.h"
+#include "Record.h"
+#include "Support/Statistic.h"
bool CodeEmitterGen::run(std::ostream &o) {
std::vector Insts;
Index: llvm/utils/TableGen/CodeEmitterGen.h
diff -u llvm/utils/TableGen/CodeEmitterGen.h:1.5 llvm/utils/TableGen/CodeEmitterGen.h:1.6
--- llvm/utils/TableGen/CodeEmitterGen.h:1.5 Wed Jul 30 23:38:26 2003
+++ llvm/utils/TableGen/CodeEmitterGen.h Wed Jul 30 23:43:49 2003
@@ -7,7 +7,9 @@
#ifndef CODEMITTERGEN_H
#define CODEMITTERGEN_H
-#include "Record.h"
+#include
+#include
+class RecordKeeper;
class CodeEmitterGen {
RecordKeeper &Records;
From tbrethou at niobe.cs.uiuc.edu Thu Jul 31 00:07:02 2003
From: tbrethou at niobe.cs.uiuc.edu (Tanya Brethour)
Date: Thu Jul 31 00:07:02 2003
Subject: [llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp
Message-ID: <200307310506.h6V56KG29479@niobe.cs.uiuc.edu>
Changes in directory llvm/lib/VMCore:
Instruction.cpp updated: 1.23 -> 1.24
---
Log message:
(null)
---
Diffs of the changes:
Index: llvm/lib/VMCore/Instruction.cpp
diff -u llvm/lib/VMCore/Instruction.cpp:1.23 llvm/lib/VMCore/Instruction.cpp:1.24
--- llvm/lib/VMCore/Instruction.cpp:1.23 Wed Jul 30 23:05:36 2003
+++ llvm/lib/VMCore/Instruction.cpp Thu Jul 31 00:06:09 2003
@@ -141,7 +141,7 @@
/// isTrappingInstruction - Return true if the instruction may trap.
///
-bool Instruction::isTrappingInstruction(unsigned op) {
+bool Instruction::isTrapping(unsigned op) {
switch(op) {
case Div:
case Rem:
From tbrethou at niobe.cs.uiuc.edu Thu Jul 31 00:09:01 2003
From: tbrethou at niobe.cs.uiuc.edu (Tanya Brethour)
Date: Thu Jul 31 00:09:01 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/Instruction.h
Message-ID: <200307310508.h6V58Cj31327@niobe.cs.uiuc.edu>
Changes in directory llvm/include/llvm:
Instruction.h updated: 1.44 -> 1.45
---
Log message:
Renamed trapping instruction function to be more consistent with other functions in the file.
---
Diffs of the changes:
Index: llvm/include/llvm/Instruction.h
diff -u llvm/include/llvm/Instruction.h:1.44 llvm/include/llvm/Instruction.h:1.45
--- llvm/include/llvm/Instruction.h:1.44 Wed Jul 30 23:05:50 2003
+++ llvm/include/llvm/Instruction.h Thu Jul 31 00:08:02 2003
@@ -99,10 +99,10 @@
/// isTrappingInstruction - Return true if the instruction may trap.
///
- bool isTrappingInstruction() const {
- return isTrappingInstruction(getOpcode());
+ bool isTrapping() const {
+ return isTrapping(getOpcode());
}
- static bool isTrappingInstruction(unsigned op);
+ static bool isTrapping(unsigned op);
virtual void print(std::ostream &OS) const;
From criswell at cs.uiuc.edu Thu Jul 31 10:12:03 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Thu Jul 31 10:12:03 2003
Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp
Message-ID: <200307311511.KAA31314@choi.cs.uiuc.edu>
Changes in directory llvm/lib/CWriter:
Writer.cpp updated: 1.111 -> 1.112
---
Log message:
Modified the code so that it generates (0) for setjmp() and abort() for
longjmp() (and does not include setjmp.h).
This is to fix some problems on Sparc while non-local jumps are still
unimplemented.
---
Diffs of the changes:
Index: llvm/lib/CWriter/Writer.cpp
diff -u llvm/lib/CWriter/Writer.cpp:1.111 llvm/lib/CWriter/Writer.cpp:1.112
--- llvm/lib/CWriter/Writer.cpp:1.111 Fri Jul 25 15:21:06 2003
+++ llvm/lib/CWriter/Writer.cpp Thu Jul 31 10:11:08 2003
@@ -570,7 +570,9 @@
// get declaration for alloca
Out << "/* Provide Declarations */\n";
Out << "#include \n";
+#ifdef HAVE_JUMP
Out << "#include \n";
+#endif
generateCompilerSpecificCode(Out);
// Provide a definition for `bool' if not compiling with a C++ compiler.
@@ -1123,16 +1125,32 @@
return;
case LLVMIntrinsic::setjmp:
+#ifdef HAVE_JUMP
Out << "setjmp(*(jmp_buf*)";
writeOperand(I.getOperand(1));
Out << ")";
+#else
+ //
+ // For right now, we don't really support non-local jumps. So
+ // make setjmp() always evaluate to zero for now.
+ //
+ Out << "(0)";
+#endif
return;
case LLVMIntrinsic::longjmp:
+#ifdef HAVE_JUMP
Out << "longjmp(*(jmp_buf*)";
writeOperand(I.getOperand(1));
Out << ", ";
writeOperand(I.getOperand(2));
Out << ")";
+#else
+ //
+ // For right now, we don't really support non-local jumps. So
+ // make longjmp() abort the program.
+ //
+ Out << "abort()";
+#endif
return;
}
}
From lattner at cs.uiuc.edu Thu Jul 31 11:06:02 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Jul 31 11:06:02 2003
Subject: [llvm-commits] CVS: llvm/utils/NightlyTest.pl
Message-ID: <200307311605.LAA29470@apoc.cs.uiuc.edu>
Changes in directory llvm/utils:
NightlyTest.pl updated: 1.16 -> 1.17
---
Log message:
Forget about KEEP_SYMBOLS, make sure to build into the temp directory, not into localhome
---
Diffs of the changes:
Index: llvm/utils/NightlyTest.pl
diff -u llvm/utils/NightlyTest.pl:1.16 llvm/utils/NightlyTest.pl:1.17
--- llvm/utils/NightlyTest.pl:1.16 Mon Jul 7 16:27:40 2003
+++ llvm/utils/NightlyTest.pl Thu Jul 31 11:05:11 2003
@@ -151,9 +151,7 @@
# Build the entire tree, saving build messages to the build log
#
if (!$NOCHECKOUT) {
- system "(time -p ./configure --enable-jit) > $Prefix-Build-Log.txt 2>&1";
- # Change the Makefile.config to not strip executables...
- system "echo 'KEEP_SYMBOLS := 1' >> Makefile.config";
+ system "(time -p ./configure --enable-jit --with-objroot=.) > $Prefix-Build-Log.txt 2>&1";
# Build the entire tree, capturing the output into $Prefix-Build-Log.txt
system "(time -p gmake $MAKEOPTS) >> $Prefix-Build-Log.txt 2>&1";
From criswell at cs.uiuc.edu Thu Jul 31 11:46:01 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Thu Jul 31 11:46:01 2003
Subject: [llvm-commits] CVS: llvm/configure
Message-ID: <200307311645.LAA06550@choi.cs.uiuc.edu>
Changes in directory llvm:
configure updated: 1.11 -> 1.12
---
Log message:
Changed the default location of OBJ_ROOT to follow these rules:
1. If USER is defined and localhome/$USER is a directory, set OBJ_ROOT
to /localhome/$USER
2. Otherwise, set OBJ_ROOT to .
This should hopefully fix the nightly tester.
---
Diffs of the changes:
Index: llvm/configure
diff -u llvm/configure:1.11 llvm/configure:1.12
--- llvm/configure:1.11 Tue Jul 29 14:11:46 2003
+++ llvm/configure Thu Jul 31 11:45:35 2003
@@ -22079,10 +22079,16 @@
fi;
-if test -d /localhome
+if test ${USER}
then
- OBJROOT=/localhome/$USER
+ if test -d /localhome/${USER}
+ then
+ OBJROOT=/localhome/${USER}
+ else
+ OBJROOT=.
+
+ fi
else
OBJROOT=.
From criswell at cs.uiuc.edu Thu Jul 31 11:46:06 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Thu Jul 31 11:46:06 2003
Subject: [llvm-commits] CVS: llvm/autoconf/configure.ac
Message-ID: <200307311645.LAA06557@choi.cs.uiuc.edu>
Changes in directory llvm/autoconf:
configure.ac updated: 1.3 -> 1.4
---
Log message:
Changed the default location of OBJ_ROOT to follow these rules:
1. If USER is defined and localhome/$USER is a directory, set OBJ_ROOT
to /localhome/$USER
2. Otherwise, set OBJ_ROOT to .
This should hopefully fix the nightly tester.
---
Diffs of the changes:
Index: llvm/autoconf/configure.ac
diff -u llvm/autoconf/configure.ac:1.3 llvm/autoconf/configure.ac:1.4
--- llvm/autoconf/configure.ac:1.3 Tue Jul 29 14:11:50 2003
+++ llvm/autoconf/configure.ac Thu Jul 31 11:45:37 2003
@@ -311,9 +311,14 @@
AC_ARG_WITH(purify,AC_HELP_STRING([--with-purify],[Location of purify program]),AC_SUBST(PURIFY,[$withval]))
dnl Location for placing object files and built programs, libraries, etc
-if test -d /localhome
+if test ${USER}
then
- AC_SUBST(OBJROOT,[/localhome/$USER])
+ if test -d /localhome/${USER}
+ then
+ AC_SUBST(OBJROOT,[/localhome/${USER}])
+ else
+ AC_SUBST(OBJROOT,[.])
+ fi
else
AC_SUBST(OBJROOT,[.])
fi
From gaeke at cs.uiuc.edu Thu Jul 31 12:40:01 2003
From: gaeke at cs.uiuc.edu (Brian Gaeke)
Date: Thu Jul 31 12:40:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/X86/Printer.cpp
Message-ID: <200307311739.MAA26436@neo.cs.uiuc.edu>
Changes in directory llvm/lib/Target/X86:
Printer.cpp updated: 1.50 -> 1.51
---
Log message:
I think local symbols in X86 GAS have to start with .L, not just
.; so I have changed the basic block markers to start with .L. I also
broke up a >80char line.
---
Diffs of the changes:
Index: llvm/lib/Target/X86/Printer.cpp
diff -u llvm/lib/Target/X86/Printer.cpp:1.50 llvm/lib/Target/X86/Printer.cpp:1.51
--- llvm/lib/Target/X86/Printer.cpp:1.50 Thu Jul 24 15:20:44 2003
+++ llvm/lib/Target/X86/Printer.cpp Thu Jul 31 12:38:52 2003
@@ -431,7 +431,7 @@
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
I != E; ++I) {
// Print a label for the basic block.
- O << ".BB" << NumberForBB[I->getBasicBlock()] << ":\t# "
+ O << ".LBB" << NumberForBB[I->getBasicBlock()] << ":\t# "
<< I->getBasicBlock()->getName() << "\n";
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
@@ -485,11 +485,13 @@
ValueMapTy::const_iterator i = NumberForBB.find(MO.getVRegValue());
assert (i != NumberForBB.end()
&& "Could not find a BB I previously put in the NumberForBB map!");
- O << ".BB" << i->second << " # PC rel: " << MO.getVRegValue()->getName();
+ O << ".LBB" << i->second << " # PC rel: " << MO.getVRegValue()->getName();
}
return;
case MachineOperand::MO_GlobalAddress:
- if (!elideOffsetKeyword) O << "OFFSET "; O << Mang->getValueName(MO.getGlobal());
+ if (!elideOffsetKeyword)
+ O << "OFFSET ";
+ O << Mang->getValueName(MO.getGlobal());
return;
case MachineOperand::MO_ExternalSymbol:
O << MO.getSymbolName();
From lattner at cs.uiuc.edu Thu Jul 31 12:48:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Jul 31 12:48:01 2003
Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp
Message-ID: <200307311747.MAA06744@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/CWriter:
Writer.cpp updated: 1.112 -> 1.113
---
Log message:
Unbreak the CBE output
---
Diffs of the changes:
Index: llvm/lib/CWriter/Writer.cpp
diff -u llvm/lib/CWriter/Writer.cpp:1.112 llvm/lib/CWriter/Writer.cpp:1.113
--- llvm/lib/CWriter/Writer.cpp:1.112 Thu Jul 31 10:11:08 2003
+++ llvm/lib/CWriter/Writer.cpp Thu Jul 31 12:47:24 2003
@@ -570,9 +570,7 @@
// get declaration for alloca
Out << "/* Provide Declarations */\n";
Out << "#include \n";
-#ifdef HAVE_JUMP
Out << "#include \n";
-#endif
generateCompilerSpecificCode(Out);
// Provide a definition for `bool' if not compiling with a C++ compiler.
From brukman at cs.uiuc.edu Thu Jul 31 12:51:01 2003
From: brukman at cs.uiuc.edu (Misha Brukman)
Date: Thu Jul 31 12:51:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/X86/README.txt
Message-ID: <200307311750.MAA05107@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/X86:
README.txt updated: 1.6 -> 1.7
---
Log message:
Changed pointer to the JIT code to its current location, under LLI.
---
Diffs of the changes:
Index: llvm/lib/Target/X86/README.txt
diff -u llvm/lib/Target/X86/README.txt:1.6 llvm/lib/Target/X86/README.txt:1.7
--- llvm/lib/Target/X86/README.txt:1.6 Sun Jan 12 18:35:08 2003
+++ llvm/lib/Target/X86/README.txt Thu Jul 31 12:50:35 2003
@@ -147,7 +147,7 @@
rest of the compiler working. It contains any code that is truly specific to
the X86 backend, for example the instruction selector and machine code emitter.
-tools/jello
+tools/lli/JIT
-----------
This directory contains the top-level code for the JIT compiler. This code
basically boils down to a call to TargetMachine::addPassesToJITCompile. As we
From lattner at cs.uiuc.edu Thu Jul 31 12:57:00 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Jul 31 12:57:00 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/X86/README.txt
Message-ID: <200307311756.MAA07401@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Target/X86:
README.txt updated: 1.7 -> 1.8
---
Log message:
Remove more obsolete comments
---
Diffs of the changes:
Index: llvm/lib/Target/X86/README.txt
diff -u llvm/lib/Target/X86/README.txt:1.7 llvm/lib/Target/X86/README.txt:1.8
--- llvm/lib/Target/X86/README.txt:1.7 Thu Jul 31 12:50:35 2003
+++ llvm/lib/Target/X86/README.txt Thu Jul 31 12:56:05 2003
@@ -2,8 +2,6 @@
//
// This file contains random notes and points of interest about the X86 backend.
//
-// Snippets of this document will probably become the final report for CS497
-//
//===----------------------------------------------------------------------===//
===========
@@ -81,38 +79,6 @@
specify a destination register to the BuildMI call.
-======================================
-III. Lazy Function Resolution in Jello
-======================================
-
-Jello is a designed to be a JIT compiler for LLVM code. This implies that call
-instructions may be emitted before the function they call is compiled. In order
-to support this, Jello currently emits unresolved call instructions to call to a
-null pointer. When the call instruction is executed, a segmentation fault will
-be generated.
-
-Jello installs a trap handler for SIGSEGV, in order to trap these events. When
-a SIGSEGV occurs, first we check to see if it's due to lazy function resolution,
-if so, we look up the return address of the function call (which was pushed onto
-the stack by the call instruction). Given the return address of the call, we
-consult a map to figure out which function was supposed to be called from that
-location.
-
-If the function has not been code generated yet, it is at this time. Finally,
-the EIP of the process is modified to point to the real function address, the
-original call instruction is updated, and the SIGSEGV handler returns, causing
-execution to start in the called function. Because we update the original call
-instruction, we should only get at most one signal for each call site.
-
-Note that this approach does not work for indirect calls. The problem with
-indirect calls is that taking the address of a function would not cause a fault
-(it would simply copy null into a register), so we would only find out about the
-problem when the indirect call itself was made. At this point we would have no
-way of knowing what the intended function destination was. Because of this, we
-immediately code generate functions whenever they have their address taken,
-side-stepping the problem completely.
-
-
======================
IV. Source Code Layout
======================
@@ -148,7 +114,7 @@
the X86 backend, for example the instruction selector and machine code emitter.
tools/lli/JIT
------------
+-------------
This directory contains the top-level code for the JIT compiler. This code
basically boils down to a call to TargetMachine::addPassesToJITCompile. As we
progress with the project, this will also contain the compile-dispatch-recompile
@@ -156,8 +122,7 @@
test/Regression/Jello
---------------------
-This directory contains regression tests for the JIT. Initially it contains a
-bunch of really trivial testcases that we should build up to supporting.
+This directory contains regression tests for the JIT.
==================================================
@@ -191,11 +156,6 @@
There are a large number of things remaining to do. Here is a partial list:
-Critical path:
--------------
-
-1. Finish dumb instruction selector
-
Next Phase:
-----------
1. Implement linear time optimal instruction selector
@@ -216,11 +176,3 @@
2. PassManager needs to be able to run just a single function through a pipeline
of FunctionPass's.
-
-3. llvmgcc needs to be modified to output 32-bit little endian LLVM files.
- Preferably it will be parameterizable so that multiple binaries need not
- exist. Until this happens, we will be restricted to using type safe
- programs (most of the Olden suite and many smaller tests), which should be
- sufficient for our 497 project. Additionally there are a few places in the
- LLVM infrastructure where we assume Sparc TargetData layout. These should
- be easy to factor out and identify though.
From lattner at cs.uiuc.edu Thu Jul 31 14:32:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Jul 31 14:32:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Support/Timer.cpp
Message-ID: <200307311931.OAA22504@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Support:
Timer.cpp updated: 1.21 -> 1.22
---
Log message:
Trivial cleanups: no need to include header twice. Global variable is local to file
---
Diffs of the changes:
Index: llvm/lib/Support/Timer.cpp
diff -u llvm/lib/Support/Timer.cpp:1.21 llvm/lib/Support/Timer.cpp:1.22
--- llvm/lib/Support/Timer.cpp:1.21 Mon Jun 30 16:58:48 2003
+++ llvm/lib/Support/Timer.cpp Thu Jul 31 14:31:21 2003
@@ -4,8 +4,6 @@
//
//===----------------------------------------------------------------------===//
-#include "Config/malloc.h"
-
#include "Support/Timer.h"
#include "Support/CommandLine.h"
@@ -19,7 +17,7 @@
#include
#include
-std::string LibSupportInfoOutputFilename;
+static std::string LibSupportInfoOutputFilename;
namespace {
#ifdef HAVE_MALLINFO
From lattner at cs.uiuc.edu Thu Jul 31 14:39:00 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Jul 31 14:39:00 2003
Subject: [llvm-commits] CVS: llvm/lib/Support/Timer.cpp
Message-ID: <200307311938.OAA26504@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Support:
Timer.cpp updated: 1.22 -> 1.23
---
Log message:
Fix the JIT in the Nightly tester. This was not a fun bug to track down.
See the comments in the patch for details.
---
Diffs of the changes:
Index: llvm/lib/Support/Timer.cpp
diff -u llvm/lib/Support/Timer.cpp:1.22 llvm/lib/Support/Timer.cpp:1.23
--- llvm/lib/Support/Timer.cpp:1.22 Thu Jul 31 14:31:21 2003
+++ llvm/lib/Support/Timer.cpp Thu Jul 31 14:38:34 2003
@@ -17,7 +17,18 @@
#include
#include
-static std::string LibSupportInfoOutputFilename;
+// getLibSupportInfoOutputFilename - This ugly hack is brought to you courtesy
+// of constructor/destructor ordering being unspecified by C++. Basically the
+// problem is that a Statistic<> object gets destroyed, which ends up calling
+// 'GetLibSupportInfoOutputFile()' (below), which calls this function.
+// LibSupportInfoOutputFilename used to be a global variable, but sometimes it
+// would get destroyed before the Statistic, causing havoc to ensue. We "fix"
+// this by creating the string the first time it is needed and never destroying
+// it.
+static std::string &getLibSupportInfoOutputFilename() {
+ static std::string *LibSupportInfoOutputFilename = new std::string();
+ return *LibSupportInfoOutputFilename;
+}
namespace {
#ifdef HAVE_MALLINFO
@@ -30,7 +41,7 @@
cl::opt
InfoOutputFilename("info-output-file",
cl::desc("File to append -stats and -timer output to"),
- cl::Hidden, cl::location(LibSupportInfoOutputFilename));
+ cl::Hidden, cl::location(getLibSupportInfoOutputFilename()));
}
static TimerGroup *DefaultTimerGroup = 0;
@@ -232,6 +243,7 @@
// GetLibSupportInfoOutputFile - Return a file stream to print our output on...
std::ostream *GetLibSupportInfoOutputFile() {
+ std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename();
if (LibSupportInfoOutputFilename.empty())
return &std::cerr;
if (LibSupportInfoOutputFilename == "-")
From criswell at cs.uiuc.edu Thu Jul 31 16:00:02 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Thu Jul 31 16:00:02 2003
Subject: [llvm-commits] CVS: llvm/autoconf/ltmain.sh
Message-ID: <200307312059.PAA29841@choi.cs.uiuc.edu>
Changes in directory llvm/autoconf:
ltmain.sh updated: 1.1 -> 1.2
---
Log message:
Removed the -only-static option as it is no longer required (and didn't work
with the newer version of libtool anyway).
---
Diffs of the changes:
Index: llvm/autoconf/ltmain.sh
diff -u llvm/autoconf/ltmain.sh:1.1 llvm/autoconf/ltmain.sh:1.2
--- llvm/autoconf/ltmain.sh:1.1 Tue Jul 22 14:13:20 2003
+++ llvm/autoconf/ltmain.sh Thu Jul 31 15:59:32 2003
@@ -405,11 +405,6 @@
continue
;;
- -only-static)
- build_libtool_libs=no
- continue
- ;;
-
-prefer-pic)
pic_mode=yes
continue
From criswell at cs.uiuc.edu Thu Jul 31 16:01:01 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Thu Jul 31 16:01:01 2003
Subject: [llvm-commits] CVS: llvm/Makefile.common
Message-ID: <200307312100.QAA29853@choi.cs.uiuc.edu>
Changes in directory llvm:
Makefile.common updated: 1.102 -> 1.103
---
Log message:
Modified the use of libtool so that we don't compile every file twice.
This can be done using the disable-shared tag that comes with libtool.
This change also required changing how .o libraries are linked.
---
Diffs of the changes:
Index: llvm/Makefile.common
diff -u llvm/Makefile.common:1.102 llvm/Makefile.common:1.103
--- llvm/Makefile.common:1.102 Wed Jul 23 11:52:46 2003
+++ llvm/Makefile.common Thu Jul 31 15:58:51 2003
@@ -272,6 +272,21 @@
endif
#
+# If we're not building a shared library, use the disable-shared tag with
+# libtool. This will disable the building of objects for shared libraries and
+# only generate static library objects.
+#
+# For dynamic libraries, we'll take the performance hit for now, since we
+# almost never build them.
+#
+# This should speed up compilation and require no modifications to future
+# versions of libtool.
+#
+ifndef SHARED_LIBRARY
+LIBTOOL := $(LIBTOOL) --tag=disable-shared
+endif
+
+#
# Verbosity levels
#
ifndef VERBOSE
@@ -323,18 +338,6 @@
Compile := $(LIBTOOL) --mode=compile $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
CompileC := $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CCFLAGS) $(CompileCommonOpts)
-#
-# Add the LLVM specific "-only-static" option so that we only compile .o files
-# once when not building a shared library.
-#
-# For shared libraries, we will end up building twice, but that doesn't happen
-# very often, so we'll let it go.
-#
-ifndef SHARED_LIBRARY
-Compile := $(Compile) -only-static
-CompileC := $(CompileC) -only-static
-endif
-
# Compile a cpp file, don't link...
CompileG := $(Compile) -g -D_DEBUG
CompileO := $(Compile) $(CompileOptimizeOpts) -felide-constructors -fomit-frame-pointer
@@ -365,7 +368,11 @@
LinkP := $(Link) -O3 -L$(PROJLIBPROFILESOURCE) -L$(LLVMLIBPROFILESOURCE) $(PROFILE)
# Create one .o file from a bunch of .o files...
+#ifdef SHARED_LIBRARY
Relink = ${LIBTOOL} --mode=link $(CXX)
+#else
+Relink = ${LIBTOOL} --mode=link $(CXX) -only-static
+#endif
# MakeSO - Create a .so file from a .o files...
#MakeSO := $(LIBTOOL) --mode=link $(CXX) $(MakeSharedObjectOption)
@@ -400,11 +407,22 @@
Source := $(ExtraSource) $(wildcard *.cpp *.c *.y *.l)
endif
+#
+# Libtool Objects
+#
Objs := $(sort $(patsubst Debug/%.lo, %.lo, $(addsuffix .lo,$(notdir $(basename $(Source))))))
ObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(Objs))
ObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(Objs))
ObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(Objs))
+#
+# The real objects underlying the libtool objects
+#
+RObjs := $(sort $(patsubst Debug/%.o, %.o, $(addsuffix .o,$(notdir $(basename $(Source))))))
+RObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(RObjs))
+RObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(RObjs))
+RObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(RObjs))
+
#---------------------------------------------------------
# Handle the DIRS and PARALLEL_DIRS options
#---------------------------------------------------------
@@ -536,17 +554,28 @@
#
# Rules for building .o libraries.
#
+# JTC:
+# Note that for this special case, we specify the actual object files
+# instead of their libtool counterparts. This is because libtool
+# doesn't want to generate a reloadable object file unless it is given
+# .o files explicitly.
+#
+# Note that we're making an assumption here: If we build a .lo file,
+# it's corresponding .o file will be placed in the same directory.
+#
+# I think that is safe.
+#
$(LIBNAME_OBJO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
@echo "Linking $@"
- $(VERB) $(Relink) -o $@ $(ObjectsO) $(LibSubDirs)
+ $(VERB) $(Relink) -o $@ $(RObjectsO) $(LibSubDirs)
$(LIBNAME_OBJP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
@echo "Linking $@"
- $(VERB) $(Relink) -o $@ $(ObjectsP) $(LibSubDirs)
+ $(VERB) $(Relink) -o $@ $(RObjectsP) $(LibSubDirs)
$(LIBNAME_OBJG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
@echo "Linking $@"
- $(VERB) $(Relink) -o $@ $(ObjectsG) $(LibSubDirs)
+ $(VERB) $(Relink) -o $@ $(RObjectsG) $(LibSubDirs)
endif
@@ -788,13 +817,6 @@
#
SourceBaseNames := $(basename $(notdir $(filter-out Debug/%, $(Source))))
SourceDepend := $(SourceBaseNames:%=$(BUILD_OBJ_DIR)/Depend/%.d)
-
-#
-# Depend target:
-# This allows a user to manually ask for an update in the dependencies
-#
-depend: $(SourceDepend)
-
# Create dependencies for the *.cpp files...
#$(SourceDepend): \x
From lattner at cs.uiuc.edu Thu Jul 31 22:49:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Jul 31 22:49:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.h
Message-ID: <200308010348.WAA14680@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Target/X86:
X86RegisterInfo.h updated: 1.13 -> 1.14
---
Log message:
This method is long dead
---
Diffs of the changes:
Index: llvm/lib/Target/X86/X86RegisterInfo.h
diff -u llvm/lib/Target/X86/X86RegisterInfo.h:1.13 llvm/lib/Target/X86/X86RegisterInfo.h:1.14
--- llvm/lib/Target/X86/X86RegisterInfo.h:1.13 Sat Dec 28 14:32:54 2002
+++ llvm/lib/Target/X86/X86RegisterInfo.h Thu Jul 31 22:48:42 2003
@@ -16,9 +16,6 @@
const unsigned* getCalleeSaveRegs() const;
- /// Returns register class appropriate for input SSA register
- ///
- const TargetRegisterClass *getClassForReg(unsigned Reg) const;
const TargetRegisterClass* getRegClassForType(const Type* Ty) const;
/// Code Generation virtual methods...
From lattner at cs.uiuc.edu Thu Jul 31 23:11:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Jul 31 23:11:01 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/CodeEmitterGen.cpp Record.h Record.cpp
Message-ID: <200308010410.XAA16771@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
CodeEmitterGen.cpp updated: 1.16 -> 1.17
Record.h updated: 1.17 -> 1.18
Record.cpp updated: 1.11 -> 1.12
---
Log message:
Factor code out into a new getAllDerivedDefinitions method, which is generally useful
---
Diffs of the changes:
Index: llvm/utils/TableGen/CodeEmitterGen.cpp
diff -u llvm/utils/TableGen/CodeEmitterGen.cpp:1.16 llvm/utils/TableGen/CodeEmitterGen.cpp:1.17
--- llvm/utils/TableGen/CodeEmitterGen.cpp:1.16 Wed Jul 30 23:43:49 2003
+++ llvm/utils/TableGen/CodeEmitterGen.cpp Thu Jul 31 23:09:58 2003
@@ -12,13 +12,8 @@
std::vector Insts;
const std::map &Defs = Records.getDefs();
- Record *Inst = Records.getClass("Instruction");
- assert(Inst && "Couldn't find Instruction class!");
- for (std::map::const_iterator I = Defs.begin(),
- E = Defs.end(); I != E; ++I)
- if (I->second->isSubClassOf(Inst))
- Insts.push_back(I->second);
+ Records.getAllDerivedDefinitions("Instruction", Insts);
std::string Namespace = "V9::";
std::string ClassName = "SparcV9CodeEmitter::";
Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.17 llvm/utils/TableGen/Record.h:1.18
--- llvm/utils/TableGen/Record.h:1.17 Wed Jul 30 23:37:57 2003
+++ llvm/utils/TableGen/Record.h Thu Jul 31 23:09:58 2003
@@ -628,6 +628,16 @@
Defs.insert(std::make_pair(R->getName(), R));
}
+ //===--------------------------------------------------------------------===//
+ // High-level helper methods, useful for tablegen backends...
+
+ /// getAllDerivedDefinitions - This method returns all concrete definitions
+ /// that derive from the specified class name. If a class with the specified
+ /// name does not exist, an error is printed and true is returned.
+ bool getAllDerivedDefinitions(const std::string &ClassName,
+ std::vector &ReturnDefs) const;
+
+
void dump() const;
};
Index: llvm/utils/TableGen/Record.cpp
diff -u llvm/utils/TableGen/Record.cpp:1.11 llvm/utils/TableGen/Record.cpp:1.12
--- llvm/utils/TableGen/Record.cpp:1.11 Tue Jul 29 23:16:52 2003
+++ llvm/utils/TableGen/Record.cpp Thu Jul 31 23:09:58 2003
@@ -468,3 +468,23 @@
OS << "def " << *I->second;
return OS;
}
+
+
+/// getAllDerivedDefinitions - This method returns all concrete definitions
+/// that derive from the specified class name. If a class with the specified
+/// name does not exist, an error is printed and true is returned.
+bool RecordKeeper::getAllDerivedDefinitions(const std::string &ClassName,
+ std::vector &Defs) const {
+ Record *Class = Records.getClass(ClassName);
+ if (!Class) {
+ std::cerr << "ERROR: Couldn't find the '" << ClassName << "' class!\n";
+ return true;
+ }
+
+ for (std::map::const_iterator I = getDefs().begin(),
+ E = getDefs().end(); I != E; ++I)
+ if (I->second->isSubClassOf(Class))
+ Defs.push_back(I->second);
+
+ return false;
+}
From lattner at cs.uiuc.edu Thu Jul 31 23:16:02 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Jul 31 23:16:02 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/CodeEmitterGen.cpp
Message-ID: <200308010415.XAA17922@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
CodeEmitterGen.cpp updated: 1.17 -> 1.18
---
Log message:
Minor cleanups
---
Diffs of the changes:
Index: llvm/utils/TableGen/CodeEmitterGen.cpp
diff -u llvm/utils/TableGen/CodeEmitterGen.cpp:1.17 llvm/utils/TableGen/CodeEmitterGen.cpp:1.18
--- llvm/utils/TableGen/CodeEmitterGen.cpp:1.17 Thu Jul 31 23:09:58 2003
+++ llvm/utils/TableGen/CodeEmitterGen.cpp Thu Jul 31 23:15:25 2003
@@ -10,10 +10,7 @@
bool CodeEmitterGen::run(std::ostream &o) {
std::vector Insts;
-
- const std::map &Defs = Records.getDefs();
-
- Records.getAllDerivedDefinitions("Instruction", Insts);
+ if (Records.getAllDerivedDefinitions("Instruction", Insts)) return true;
std::string Namespace = "V9::";
std::string ClassName = "SparcV9CodeEmitter::";
@@ -25,8 +22,7 @@
<< " DEBUG(std::cerr << MI);\n"
<< " switch (MI.getOpcode()) {\n";
for (std::vector::iterator I = Insts.begin(), E = Insts.end();
- I != E; ++I)
- {
+ I != E; ++I) {
Record *R = *I;
o << " case " << Namespace << R->getName() << ": {\n"
<< " DEBUG(std::cerr << \"Emitting " << R->getName() << "\\n\");\n";
From lattner at cs.uiuc.edu Thu Jul 31 23:39:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Jul 31 23:39:01 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/Record.h Record.cpp
Message-ID: <200308010438.XAA20551@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
Record.h updated: 1.18 -> 1.19
Record.cpp updated: 1.12 -> 1.13
---
Log message:
Switch over to an exception handling model for "high-level" requests.
Add new getValueAsString method.
---
Diffs of the changes:
Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.18 llvm/utils/TableGen/Record.h:1.19
--- llvm/utils/TableGen/Record.h:1.18 Thu Jul 31 23:09:58 2003
+++ llvm/utils/TableGen/Record.h Thu Jul 31 23:37:57 2003
@@ -319,6 +319,8 @@
public:
StringInit(const std::string &V) : Value(V) {}
+ const std::string &getValue() const { return Value; }
+
virtual Init *convertInitializerTo(RecTy *Ty) {
return Ty->convertValue(this);
}
@@ -592,6 +594,17 @@
void resolveReferences();
void dump() const;
+
+ //===--------------------------------------------------------------------===//
+ // High-level methods useful to tablegen back-ends
+ //
+
+ /// getValueAsString - This method looks up the specified field and returns
+ /// its value as a string, throwing an exception if the field does not exist
+ /// or if the value is not a string.
+ ///
+ std::string getValueAsString(const std::string &FieldName) const;
+
};
std::ostream &operator<<(std::ostream &OS, const Record &R);
@@ -633,9 +646,9 @@
/// getAllDerivedDefinitions - This method returns all concrete definitions
/// that derive from the specified class name. If a class with the specified
- /// name does not exist, an error is printed and true is returned.
- bool getAllDerivedDefinitions(const std::string &ClassName,
- std::vector &ReturnDefs) const;
+ /// name does not exist, an exception is thrown.
+ std::vector
+ getAllDerivedDefinitions(const std::string &ClassName) const;
void dump() const;
Index: llvm/utils/TableGen/Record.cpp
diff -u llvm/utils/TableGen/Record.cpp:1.12 llvm/utils/TableGen/Record.cpp:1.13
--- llvm/utils/TableGen/Record.cpp:1.12 Thu Jul 31 23:09:58 2003
+++ llvm/utils/TableGen/Record.cpp Thu Jul 31 23:37:57 2003
@@ -452,6 +452,23 @@
return OS << "}\n";
}
+/// getValueAsString - This method looks up the specified field and returns its
+/// value as a string, throwing an exception if the field does not exist or if
+/// the value is not a string.
+///
+std::string Record::getValueAsString(const std::string &FieldName) const {
+ const RecordVal *R = getValue(FieldName);
+ if (R == 0 || R->getValue() == 0)
+ throw "Record '" + R->getName() + "' does not have a field named '" +
+ FieldName + "!\n";
+
+ if (const StringInit *SI = dynamic_cast(R->getValue()))
+ return SI->getValue();
+ throw "Record '" + R->getName() + "', field '" + FieldName +
+ "' does not have a string initializer!";
+}
+
+
void RecordKeeper::dump() const { std::cerr << *this; }
std::ostream &operator<<(std::ostream &OS, const RecordKeeper &RK) {
@@ -473,18 +490,17 @@
/// getAllDerivedDefinitions - This method returns all concrete definitions
/// that derive from the specified class name. If a class with the specified
/// name does not exist, an error is printed and true is returned.
-bool RecordKeeper::getAllDerivedDefinitions(const std::string &ClassName,
- std::vector &Defs) const {
+std::vector
+RecordKeeper::getAllDerivedDefinitions(const std::string &ClassName) const {
Record *Class = Records.getClass(ClassName);
- if (!Class) {
- std::cerr << "ERROR: Couldn't find the '" << ClassName << "' class!\n";
- return true;
- }
+ if (!Class)
+ throw "ERROR: Couldn't find the '" + ClassName + "' class!\n";
+ std::vector Defs;
for (std::map::const_iterator I = getDefs().begin(),
E = getDefs().end(); I != E; ++I)
if (I->second->isSubClassOf(Class))
Defs.push_back(I->second);
- return false;
+ return Defs;
}
From lattner at cs.uiuc.edu Thu Jul 31 23:39:06 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Jul 31 23:39:06 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/CodeEmitterGen.cpp CodeEmitterGen.h
Message-ID: <200308010438.XAA20566@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
CodeEmitterGen.cpp updated: 1.18 -> 1.19
CodeEmitterGen.h updated: 1.6 -> 1.7
---
Log message:
Simplify code to match new interfaces
---
Diffs of the changes:
Index: llvm/utils/TableGen/CodeEmitterGen.cpp
diff -u llvm/utils/TableGen/CodeEmitterGen.cpp:1.18 llvm/utils/TableGen/CodeEmitterGen.cpp:1.19
--- llvm/utils/TableGen/CodeEmitterGen.cpp:1.18 Thu Jul 31 23:15:25 2003
+++ llvm/utils/TableGen/CodeEmitterGen.cpp Thu Jul 31 23:38:18 2003
@@ -8,9 +8,8 @@
#include "Record.h"
#include "Support/Statistic.h"
-bool CodeEmitterGen::run(std::ostream &o) {
- std::vector Insts;
- if (Records.getAllDerivedDefinitions("Instruction", Insts)) return true;
+void CodeEmitterGen::run(std::ostream &o) {
+ std::vector Insts = Records.getAllDerivedDefinitions("Instruction");
std::string Namespace = "V9::";
std::string ClassName = "SparcV9CodeEmitter::";
@@ -28,10 +27,8 @@
<< " DEBUG(std::cerr << \"Emitting " << R->getName() << "\\n\");\n";
const RecordVal *InstVal = R->getValue("Inst");
- if (!InstVal) {
- std::cerr << "No 'Inst' record found in target description file!\n";
- return true;
- }
+ if (!InstVal)
+ throw std::string("No 'Inst' record found in target description file!");
Init *InitVal = InstVal->getValue();
assert(dynamic_cast(InitVal) &&
@@ -226,5 +223,4 @@
<< " }\n"
<< " return Value;\n"
<< "}\n";
- return false;
}
Index: llvm/utils/TableGen/CodeEmitterGen.h
diff -u llvm/utils/TableGen/CodeEmitterGen.h:1.6 llvm/utils/TableGen/CodeEmitterGen.h:1.7
--- llvm/utils/TableGen/CodeEmitterGen.h:1.6 Wed Jul 30 23:43:49 2003
+++ llvm/utils/TableGen/CodeEmitterGen.h Thu Jul 31 23:38:18 2003
@@ -16,8 +16,8 @@
public:
CodeEmitterGen(RecordKeeper &R) : Records(R) {}
- // run - Output the code emitter, returning true on failure.
- bool run(std::ostream &o);
+ // run - Output the code emitter
+ void run(std::ostream &o);
private:
void emitMachineOpEmitter(std::ostream &o, const std::string &Namespace);
void emitGetValueBit(std::ostream &o, const std::string &Namespace);
From lattner at cs.uiuc.edu Thu Jul 31 23:40:00 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Jul 31 23:40:00 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/TableGen.cpp
Message-ID: <200308010439.XAA20586@apoc.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
TableGen.cpp updated: 1.10 -> 1.11
---
Log message:
Add file comment
Add register info emitter
Simplify code by using "high-level" methods.
---
Diffs of the changes:
Index: llvm/utils/TableGen/TableGen.cpp
diff -u llvm/utils/TableGen/TableGen.cpp:1.10 llvm/utils/TableGen/TableGen.cpp:1.11
--- llvm/utils/TableGen/TableGen.cpp:1.10 Wed Jul 30 23:38:26 2003
+++ llvm/utils/TableGen/TableGen.cpp Thu Jul 31 23:39:05 2003
@@ -1,13 +1,25 @@
+//===- TableGen.cpp - Top-Level TableGen implementation -------------------===//
+//
+// TableGen is a tool which can be used to build up a description of something,
+// then invoke one or more "tablegen backends" to emit information about the
+// description in some predefined format. In practice, this is used by the LLVM
+// code generators to automate generation of a code generator through a
+// high-level description of the target.
+//
+//===----------------------------------------------------------------------===//
+
#include "Record.h"
#include "Support/CommandLine.h"
#include "Support/Signals.h"
#include "CodeEmitterGen.h"
+#include "RegisterInfoEmitter.h"
#include
#include