[llvm-commits] CVS: llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp ARMRegisterInfo.cpp ARMRegisterInfo.td

2006-10-26 Thread Rafael Espindola


Changes in directory llvm/lib/Target/ARM:

ARMISelDAGToDAG.cpp updated: 1.79 -> 1.80
ARMRegisterInfo.cpp updated: 1.22 -> 1.23
ARMRegisterInfo.td updated: 1.5 -> 1.6
---
Log message:

initial support for frame pointers


---
Diffs of the changes:  (+44 -5)

 ARMISelDAGToDAG.cpp |3 +++
 ARMRegisterInfo.cpp |   41 +
 ARMRegisterInfo.td  |5 -
 3 files changed, 44 insertions(+), 5 deletions(-)


Index: llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
diff -u llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp:1.79 
llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp:1.80
--- llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp:1.79Tue Oct 24 15:15:21 2006
+++ llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp Thu Oct 26 08:31:25 2006
@@ -91,10 +91,13 @@
   setOperationAction(ISD::VASTART,   MVT::Other, Custom);
   setOperationAction(ISD::VACOPY,MVT::Other, Expand);
   setOperationAction(ISD::VAEND, MVT::Other, Expand);
+  setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Expand);
 
   setOperationAction(ISD::ConstantFP, MVT::f64, Expand);
   setOperationAction(ISD::ConstantFP, MVT::f32, Expand);
 
+  setStackPointerRegisterToSaveRestore(ARM::R13);
+
   setSchedulingPreference(SchedulingForRegPressure);
   computeRegisterProperties();
 }


Index: llvm/lib/Target/ARM/ARMRegisterInfo.cpp
diff -u llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.22 
llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.23
--- llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.22Tue Oct 17 09:34:02 2006
+++ llvm/lib/Target/ARM/ARMRegisterInfo.cpp Thu Oct 26 08:31:25 2006
@@ -19,10 +19,20 @@
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Type.h"
+#include "llvm/Target/TargetOptions.h"
 #include "llvm/ADT/STLExtras.h"
 #include 
 using namespace llvm;
 
+// hasFP - Return true if the specified function should have a dedicated frame
+// pointer register.  This is true if the function has variable sized allocas 
or
+// if frame pointer elimination is disabled.
+//
+static bool hasFP(const MachineFunction &MF) {
+  const MachineFrameInfo *MFI = MF.getFrameInfo();
+  return NoFramePointerElim || MFI->hasVarSizedObjects();
+}
+
 ARMRegisterInfo::ARMRegisterInfo()
   : ARMGenRegisterInfo(ARM::ADJCALLSTACKDOWN, ARM::ADJCALLSTACKUP) {
 }
@@ -88,6 +98,9 @@
 void ARMRegisterInfo::
 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
   MachineBasicBlock::iterator I) const {
+  if (hasFP(MF)) {
+assert(0);
+  }
   MBB.erase(I);
 }
 
@@ -114,17 +127,18 @@
   Offset += StackSize;
 
   assert (Offset >= 0);
+  unsigned BaseRegister = hasFP(MF) ? ARM::R11 : ARM::R13;
   if (Offset < 4096) {
 // Replace the FrameIndex with r13
-MI.getOperand(FrameIdx).ChangeToRegister(ARM::R13, false);
+MI.getOperand(FrameIdx).ChangeToRegister(BaseRegister, false);
 // Replace the ldr offset with Offset
 MI.getOperand(OffIdx).ChangeToImmediate(Offset);
   } else {
 // Insert a set of r12 with the full address
 // r12 = r13 + offset
 MachineBasicBlock *MBB2 = MI.getParent();
-BuildMI(*MBB2, II, ARM::ADD, 4, ARM::R12).addReg(ARM::R13).addImm(Offset)
-   .addImm(0).addImm(ARMShift::LSL);
+BuildMI(*MBB2, II, ARM::ADD, 4, ARM::R12).addReg(BaseRegister)
+  .addImm(Offset).addImm(0).addImm(ARMShift::LSL);
 
 // Replace the FrameIndex with r12
 MI.getOperand(FrameIdx).ChangeToRegister(ARM::R12, false);
@@ -140,6 +154,8 @@
   MachineFrameInfo  *MFI = MF.getFrameInfo();
   int   NumBytes = (int) MFI->getStackSize();
 
+  bool HasFP = hasFP(MF);
+
   if (MFI->hasCalls()) {
 // We reserve argument space for call sites in the function immediately on
 // entry to the current function.  This eliminates the need for add/sub
@@ -147,6 +163,10 @@
 NumBytes += MFI->getMaxCallFrameSize();
   }
 
+  if (HasFP)
+// Add space for storing the FP
+NumBytes += 4;
+
   // Align to 8 bytes
   NumBytes = ((NumBytes + 7) / 8) * 8;
 
@@ -155,6 +175,13 @@
   //sub sp, sp, #NumBytes
   BuildMI(MBB, MBBI, ARM::SUB, 4, ARM::R13).addReg(ARM::R13).addImm(NumBytes)
  .addImm(0).addImm(ARMShift::LSL);
+
+  if (HasFP) {
+BuildMI(MBB, MBBI, ARM::str, 3)
+  .addReg(ARM::R11).addImm(0).addReg(ARM::R13);
+BuildMI(MBB, MBBI, ARM::MOV, 3, ARM::R11).addReg(ARM::R13).addImm(0).
+  addImm(ARMShift::LSL);
+  }
 }
 
 void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
@@ -166,6 +193,12 @@
   MachineFrameInfo *MFI = MF.getFrameInfo();
   int  NumBytes = (int) MFI->getStackSize();
 
+  if (hasFP(MF)) {
+BuildMI(MBB, MBBI, ARM::MOV, 3, ARM::R13).addReg(ARM::R11).addImm(0).
+  addImm(ARMShift::LSL);
+BuildMI(MBB, MBBI, ARM::ldr, 2, ARM::R11).addImm(0).addReg(ARM::R13);
+  }
+
   //add sp, sp, #NumBytes
   BuildMI(MBB, MBBI, ARM::ADD, 4, ARM::R13).addReg(ARM::R13).addImm(NumBytes)
  .addImm(0).addImm(ARMShift::LSL);
@@ -176,7 +209,7 @@
 }
 
 unsigned 

[llvm-commits] CVS: llvm/test/Regression/CodeGen/ARM/alloca.ll

2006-10-26 Thread Rafael Espindola


Changes in directory llvm/test/Regression/CodeGen/ARM:

alloca.ll added (r1.1)
---
Log message:

initial support for frame pointers


---
Diffs of the changes:  (+5 -0)

 alloca.ll |5 +
 1 files changed, 5 insertions(+)


Index: llvm/test/Regression/CodeGen/ARM/alloca.ll
diff -c /dev/null llvm/test/Regression/CodeGen/ARM/alloca.ll:1.1
*** /dev/null   Thu Oct 26 08:31:36 2006
--- llvm/test/Regression/CodeGen/ARM/alloca.ll  Thu Oct 26 08:31:26 2006
***
*** 0 
--- 1,5 
+ void %f(uint %a) {
+ entry:
+   %tmp1032 = alloca ubyte, uint %a
+   ret void
+ }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] Div->[USF]Div Patch, Attempt #2

2006-10-26 Thread Chris Lattner
On Oct 25, 2006, at 9:57 PM, Reid Spencer wrote:
>> This code is a bit simpler as:
>>
>>
>> // (X / C1) / C2  -> X / (C1*C2)
>> if (BinaryOperator *LHS = dyn_cast(Op0))
>>   if (LHS->getOpcode() == I.getOpcode())
>>
>
> Didn't apply this because it causes a compiler warning about
> signed/unsigned comparison.

Ok.

>>   // udiv X, (Select Cond, C1, C2) --> Select Cond, (shr X, C1), (shr
>> X, C2)
>>   // where C1&C2 are powers of two.
>> ...
>> X = InsertNewInstBefore(
>>   new CastInst(X, X->getType()->getUnsignedVersion 
>> ()),
>> I);
>>
>>
>> This (and similar cases) is easier/cleaner with InsertCastBefore.
>
> Yes, I agree. I changed the ones in my code but there are actually
> dozens (hundreds) of instances in the file (not related to my  
> changes).
> I'm going to commit the DIV patch first, then I'll come back and clean
> up the others in a separate patch (tested, of course).

Ok, sounds good.

> Thanks for your excellent reviews, Chris. I know it takes a lot of  
> your
> time and I appreciate that you so willingly give it. I'll apply what I
> learned from DIV to the REM patch which I'm reviewing for Sheng soon.
> Hopefully REM will fare better than DIV did.

Sounds good, I'm sure it will get more smooth as it goes on.  Thanks  
for the great improvements Reid!

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Type.h

2006-10-26 Thread Chris Lattner


Changes in directory llvm/include/llvm:

Type.h updated: 1.90 -> 1.91
---
Log message:

Add isFPOrFPVector() method, which indicates if a type is either FP or a 
vector of FP types.


---
Diffs of the changes:  (+4 -0)

 Type.h |4 
 1 files changed, 4 insertions(+)


Index: llvm/include/llvm/Type.h
diff -u llvm/include/llvm/Type.h:1.90 llvm/include/llvm/Type.h:1.91
--- llvm/include/llvm/Type.h:1.90   Thu Sep 28 18:38:07 2006
+++ llvm/include/llvm/Type.hThu Oct 26 13:22:45 2006
@@ -185,6 +185,10 @@
   /// types
   bool isFloatingPoint() const { return ID == FloatTyID || ID == DoubleTyID; }
 
+  /// isFPOrFPVector - Return true if this is a FP type or a vector of FP 
types.
+  ///
+  bool isFPOrFPVector() const;
+  
   /// isAbstract - True if the type is either an Opaque type, or is a derived
   /// type that includes an opaque type somewhere in it.
   ///



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp

2006-10-26 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Instruction.cpp updated: 1.54 -> 1.55
---
Log message:

Fix Transforms/InstCombine/2006-10-26-VectorReassoc.ll


---
Diffs of the changes:  (+6 -5)

 Instruction.cpp |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)


Index: llvm/lib/VMCore/Instruction.cpp
diff -u llvm/lib/VMCore/Instruction.cpp:1.54 
llvm/lib/VMCore/Instruction.cpp:1.55
--- llvm/lib/VMCore/Instruction.cpp:1.54Thu Oct 26 01:15:43 2006
+++ llvm/lib/VMCore/Instruction.cpp Thu Oct 26 13:27:26 2006
@@ -172,11 +172,12 @@
 /// applied to floating point types.
 ///
 bool Instruction::isAssociative(unsigned Opcode, const Type *Ty) {
-  if (Opcode == Add || Opcode == Mul ||
-  Opcode == And || Opcode == Or || Opcode == Xor) {
-// Floating point operations do not associate!
-return !Ty->isFloatingPoint();
-  }
+  if (Opcode == And || Opcode == Or || Opcode == Xor)
+return true;
+
+  // Add/Mul reassociate unless they are FP or FP vectors.
+  if (Opcode == Add || Opcode == Mul)
+return !Ty->isFPOrFPVector();
   return 0;
 }
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/2006-10-26-VectorReassoc.ll

2006-10-26 Thread Chris Lattner


Changes in directory llvm/test/Regression/Transforms/InstCombine:

2006-10-26-VectorReassoc.ll added (r1.1)
---
Log message:

new testcase, should not reassoc fp vector


---
Diffs of the changes:  (+8 -0)

 2006-10-26-VectorReassoc.ll |8 
 1 files changed, 8 insertions(+)


Index: llvm/test/Regression/Transforms/InstCombine/2006-10-26-VectorReassoc.ll
diff -c /dev/null 
llvm/test/Regression/Transforms/InstCombine/2006-10-26-VectorReassoc.ll:1.1
*** /dev/null   Thu Oct 26 13:27:03 2006
--- llvm/test/Regression/Transforms/InstCombine/2006-10-26-VectorReassoc.ll 
Thu Oct 26 13:26:53 2006
***
*** 0 
--- 1,8 
+ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep mul | wc -l | grep 2
+ 
+ 
+ <4 x float> %test(<4 x float> %V) {
+   %Y = mul <4 x float> %V, 
+   %Z = mul <4 x float> %Y, 
+   ret <4 x float> %Z
+ }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/VMCore/Type.cpp

2006-10-26 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.148 -> 1.149
---
Log message:

Add isFPOrFPVector() method, which indicates if a type is either FP or a 
vector of FP types.


---
Diffs of the changes:  (+10 -0)

 Type.cpp |   10 ++
 1 files changed, 10 insertions(+)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.148 llvm/lib/VMCore/Type.cpp:1.149
--- llvm/lib/VMCore/Type.cpp:1.148  Fri Oct 20 02:07:24 2006
+++ llvm/lib/VMCore/Type.cppThu Oct 26 13:22:45 2006
@@ -90,6 +90,16 @@
   }
 }
 
+/// isFPOrFPVector - Return true if this is a FP type or a vector of FP types.
+///
+bool Type::isFPOrFPVector() const {
+  if (ID == Type::FloatTyID || ID == Type::DoubleTyID) return true;
+  if (ID != Type::PackedTyID) return false;
+  
+  return cast(this)->getElementType()->isFloatingPoint();
+}
+
+
 // isLosslesslyConvertibleTo - Return true if this type can be converted to
 // 'Ty' without any reinterpretation of bits.  For example, uint to int.
 //



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Target/TargetAsmInfo.h

2006-10-26 Thread Evan Cheng


Changes in directory llvm/include/llvm/Target:

TargetAsmInfo.h updated: 1.9 -> 1.10
---
Log message:

Added CStringSection.

---
Diffs of the changes:  (+9 -0)

 TargetAsmInfo.h |9 +
 1 files changed, 9 insertions(+)


Index: llvm/include/llvm/Target/TargetAsmInfo.h
diff -u llvm/include/llvm/Target/TargetAsmInfo.h:1.9 
llvm/include/llvm/Target/TargetAsmInfo.h:1.10
--- llvm/include/llvm/Target/TargetAsmInfo.h:1.9Fri Oct 13 12:50:07 2006
+++ llvm/include/llvm/Target/TargetAsmInfo.hThu Oct 26 14:16:20 2006
@@ -162,6 +162,12 @@
 /// table.
 const char *JumpTableDirective;
 
+/// CStringSection - If not null, this allows for special handling of
+/// cstring constants (\0 terminated string that does not contain any
+/// other null bytes) on this target. This is commonly supported as
+/// ".cstring".
+const char *CStringSection;   // Defaults to NULL
+
 /// StaticCtorsSection - This is the directive that is emitted to switch to
 /// a section to emit the static constructor list.
 /// Defaults to "\t.section .ctors,\"aw\",@progbits".
@@ -366,6 +372,9 @@
 const char *getJumpTableDataSection() const {
   return JumpTableDataSection;
 }
+const char *getCStringSection() const {
+  return CStringSection;
+}
 const char *getStaticCtorsSection() const {
   return StaticCtorsSection;
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Constants.h

2006-10-26 Thread Evan Cheng


Changes in directory llvm/include/llvm:

Constants.h updated: 1.91 -> 1.92
---
Log message:

Add isCString() - returns true if a ConstantArray is a CString.

---
Diffs of the changes:  (+5 -0)

 Constants.h |5 +
 1 files changed, 5 insertions(+)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.91 llvm/include/llvm/Constants.h:1.92
--- llvm/include/llvm/Constants.h:1.91  Thu Oct 26 01:15:43 2006
+++ llvm/include/llvm/Constants.h   Thu Oct 26 14:13:30 2006
@@ -334,6 +334,11 @@
   /// ubyte, and if the elements of the array are all ConstantInt's.
   bool isString() const;
 
+  /// isCString - This method returns true if the array is a string (see
+  /// isString) and it ends in a null byte \0 and does not contains any other
+  /// null bytes except its terminator.
+  bool isCString() const;
+
   /// getAsString - If this array is isString(), then this method converts the
   /// array to an std::string and returns it.  Otherwise, it asserts out.
   ///



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/X86/X86AsmPrinter.cpp X86TargetAsmInfo.cpp

2006-10-26 Thread Evan Cheng


Changes in directory llvm/lib/Target/X86:

X86AsmPrinter.cpp updated: 1.205 -> 1.206
X86TargetAsmInfo.cpp updated: 1.4 -> 1.5
---
Log message:

Put cstrings in .cstring section when compiling for Mac OS X.

---
Diffs of the changes:  (+10 -1)

 X86AsmPrinter.cpp|   10 +-
 X86TargetAsmInfo.cpp |1 +
 2 files changed, 10 insertions(+), 1 deletion(-)


Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.205 
llvm/lib/Target/X86/X86AsmPrinter.cpp:1.206
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.205 Tue Oct 24 15:32:14 2006
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp   Thu Oct 26 14:18:18 2006
@@ -204,9 +204,17 @@
 // If external or appending, declare as a global symbol
 O << "\t.globl " << name << "\n";
 // FALL THROUGH
-  case GlobalValue::InternalLinkage:
+  case GlobalValue::InternalLinkage: {
+if (TAI->getCStringSection()) {
+  const ConstantArray *CVA = dyn_cast(C);
+  if (CVA && CVA->isCString()) {
+SwitchToDataSection(TAI->getCStringSection(), I);
+break;
+  }
+}
 SwitchToDataSection(TAI->getDataSection(), I);
 break;
+  }
   default:
 assert(0 && "Unknown linkage type!");
   }


Index: llvm/lib/Target/X86/X86TargetAsmInfo.cpp
diff -u llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.4 
llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.5
--- llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.4Wed Oct  4 21:43:52 2006
+++ llvm/lib/Target/X86/X86TargetAsmInfo.cppThu Oct 26 14:18:18 2006
@@ -32,6 +32,7 @@
 PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
 ConstantPoolSection = "\t.const\n";
 JumpTableDataSection = "\t.const\n";
+CStringSection = "\t.cstring";
 FourByteConstantSection = "\t.literal4\n";
 EightByteConstantSection = "\t.literal8\n";
 if (Subtarget->is64Bit())



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp

2006-10-26 Thread Evan Cheng


Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.166 -> 1.167
---
Log message:

Add isCString() - returns true if a ConstantArray is a CString.

---
Diffs of the changes:  (+13 -0)

 Constants.cpp |   13 +
 1 files changed, 13 insertions(+)


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.166 llvm/lib/VMCore/Constants.cpp:1.167
--- llvm/lib/VMCore/Constants.cpp:1.166 Thu Oct 26 01:15:43 2006
+++ llvm/lib/VMCore/Constants.cpp   Thu Oct 26 14:15:05 2006
@@ -1073,6 +1073,19 @@
   return true;
 }
 
+/// isCString - This method returns true if the array is a string (see
+/// isString) and it ends in a null byte \0 and does not contains any other
+/// null bytes except its terminator.
+bool ConstantArray::isCString() const {
+  if (!isString()) return false;
+  // This is safe because a ConstantArray cannot be a zero array.
+  for (unsigned i = 0, e = getNumOperands()-1; i != e; ++i)
+if (cast(getOperand(i))->getZExtValue() == 0)
+  return false;
+  return true;
+}
+
+
 // getAsString - If the sub-element type of this array is either sbyte or 
ubyte,
 // then this method converts the array to an std::string and returns it.
 // Otherwise, it asserts out.



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

2006-10-26 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.528 -> 1.529
---
Log message:

Simplify code a bit by changing instances of:
   InsertNewInstBefore(new CastInst(Val, ValTy, Val->GetName()), I)
into:
   InsertCastBefore(Val, ValTy, I)


---
Diffs of the changes:  (+27 -47)

 InstructionCombining.cpp |   74 +--
 1 files changed, 27 insertions(+), 47 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.528 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.529
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.528   Thu Oct 26 
01:15:43 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Thu Oct 26 14:19:06 2006
@@ -461,9 +461,7 @@
   if (Constant *C = dyn_cast(V))
 return ConstantExpr::getCast(C, DestTy);
   
-  CastInst *CI = new CastInst(V, DestTy, V->getName());
-  InsertNewInstBefore(CI, *InsertBefore);
-  return CI;
+  return InsertCastBefore(V, DestTy, *InsertBefore);
 }
 
 // SimplifyCommutative - This performs a few simplifications for commutative
@@ -1087,13 +1085,11 @@
   // convert this into a zero extension.
   if ((KnownZero & InSignBit) || (NewBits & ~DemandedMask) == NewBits) {
 // Convert to unsigned first.
-Instruction *NewVal;
-NewVal = new CastInst(I->getOperand(0), SrcTy->getUnsignedVersion(),
-  I->getOperand(0)->getName());
-InsertNewInstBefore(NewVal, *I);
+Value *NewVal = 
+  InsertCastBefore(I->getOperand(0), SrcTy->getUnsignedVersion(), *I);
 // Then cast that to the destination type.
 NewVal = new CastInst(NewVal, I->getType(), I->getName());
-InsertNewInstBefore(NewVal, *I);
+InsertNewInstBefore(cast(NewVal), *I);
 return UpdateValueUsesWith(I, NewVal);
   } else if (KnownOne & InSignBit) {// Input sign bit known set
 KnownOne |= NewBits;
@@ -1124,17 +1120,15 @@
 // the shift amount is >= the size of the datatype, which is undefined.
 if (DemandedMask == 1 && I->getType()->isSigned()) {
   // Convert the input to unsigned.
-  Instruction *NewVal = new CastInst(I->getOperand(0), 
- I->getType()->getUnsignedVersion(),
- I->getOperand(0)->getName());
-  InsertNewInstBefore(NewVal, *I);
+  Value *NewVal = InsertCastBefore(I->getOperand(0), 
+   I->getType()->getUnsignedVersion(), *I);
   // Perform the unsigned shift right.
   NewVal = new ShiftInst(Instruction::Shr, NewVal, I->getOperand(1),
  I->getName());
-  InsertNewInstBefore(NewVal, *I);
+  InsertNewInstBefore(cast(NewVal), *I);
   // Then cast that to the destination type.
   NewVal = new CastInst(NewVal, I->getType(), I->getName());
-  InsertNewInstBefore(NewVal, *I);
+  InsertNewInstBefore(cast(NewVal), *I);
   return UpdateValueUsesWith(I, NewVal);
 }
 
@@ -1175,17 +1169,14 @@
 // are demanded, turn this into an unsigned shift right.
 if ((KnownZero & SignBit) || (HighBits & ~DemandedMask) == HighBits) {
   // Convert the input to unsigned.
-  Instruction *NewVal;
-  NewVal = new CastInst(I->getOperand(0), 
-I->getType()->getUnsignedVersion(),
-I->getOperand(0)->getName());
-  InsertNewInstBefore(NewVal, *I);
+  Value *NewVal = InsertCastBefore(I->getOperand(0), 
+ I->getType()->getUnsignedVersion(), *I);
   // Perform the unsigned shift right.
   NewVal = new ShiftInst(Instruction::Shr, NewVal, SA, I->getName());
-  InsertNewInstBefore(NewVal, *I);
+  InsertNewInstBefore(cast(NewVal), *I);
   // Then cast that to the destination type.
   NewVal = new CastInst(NewVal, I->getType(), I->getName());
-  InsertNewInstBefore(NewVal, *I);
+  InsertNewInstBefore(cast(NewVal), *I);
   return UpdateValueUsesWith(I, NewVal);
 } else if (KnownOne & SignBit) { // New bits are known one.
   KnownOne |= HighBits;
@@ -1914,15 +1905,13 @@
 SI->getType()->getPrimitiveSizeInBits()-1) {
   // Ok, the transformation is safe.  Insert a cast of the incoming
   // value, then the new shift, then the new cast.
-  Instruction *FirstCast = new CastInst(SI->getOperand(0), NewTy,
- SI->getOperand(0)->getName());
-  Value *InV = InsertNewInstBefore(FirstCast, I);
-  Instruction *NewShift = new ShiftInst(Instruction::Shr, 
FirstCast,
+  Value *InV = InsertCastBefore(SI->getOperand(0), NewTy, I);
+  Instruction *NewShift = new ShiftInst(Instr

[llvm-commits] CVS: llvm/include/llvm/LinkTimeOptimizer.h

2006-10-26 Thread Devang Patel


Changes in directory llvm/include/llvm:

LinkTimeOptimizer.h updated: 1.11 -> 1.12
---
Log message:

Save temp. bc files when saveTemps flag is true. Use final output file 
name supplied by linker to construct temp bc file names. 

Remove tabs.


---
Diffs of the changes:  (+7 -4)

 LinkTimeOptimizer.h |   11 +++
 1 files changed, 7 insertions(+), 4 deletions(-)


Index: llvm/include/llvm/LinkTimeOptimizer.h
diff -u llvm/include/llvm/LinkTimeOptimizer.h:1.11 
llvm/include/llvm/LinkTimeOptimizer.h:1.12
--- llvm/include/llvm/LinkTimeOptimizer.h:1.11  Wed Oct 25 13:10:07 2006
+++ llvm/include/llvm/LinkTimeOptimizer.h   Thu Oct 26 15:46:22 2006
@@ -91,8 +91,9 @@
   NameToSymbolMap &,
   std::set &) = 0;
 virtual enum LTOStatus optimizeModules(const std::string &,
-   std::vector &,
-   std::string &) = 0;
+   std::vector &,
+   std::string &, bool, 
+   const char *) = 0;
 virtual void getTargetTriple(const std::string &, std::string &) = 0;
 virtual void removeModule (const std::string &InputFilename) = 0;
 virtual ~LinkTimeOptimizer() = 0;
@@ -113,8 +114,10 @@
   std::set &references);
 enum LTOStatus optimizeModules(const std::string &OutputFilename,
std::vector &exportList,
-   std::string &targetTriple);
-void getTargetTriple(const std::string &InputFilename, std::string 
&targetTriple);
+   std::string &targetTriple, bool saveTemps,
+   const char *);
+void getTargetTriple(const std::string &InputFilename, 
+ std::string &targetTriple);
 void removeModule (const std::string &InputFilename);
 
 // Constructors and destructors



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/tools/lto/lto.cpp

2006-10-26 Thread Devang Patel


Changes in directory llvm/tools/lto:

lto.cpp updated: 1.24 -> 1.25
---
Log message:

Save temp. bc files when saveTemps flag is true. Use final output file 
name supplied by linker to construct temp bc file names. 

Remove tabs.


---
Diffs of the changes:  (+24 -11)

 lto.cpp |   35 ---
 1 files changed, 24 insertions(+), 11 deletions(-)


Index: llvm/tools/lto/lto.cpp
diff -u llvm/tools/lto/lto.cpp:1.24 llvm/tools/lto/lto.cpp:1.25
--- llvm/tools/lto/lto.cpp:1.24 Wed Oct 25 13:10:07 2006
+++ llvm/tools/lto/lto.cpp  Thu Oct 26 15:46:22 2006
@@ -129,7 +129,7 @@
 /// set corresponding target triplet string.
 void
 LTO::getTargetTriple(const std::string &InputFilename, 
-  std::string &targetTriple)
+ std::string &targetTriple)
 {
   Module *m = getModule(InputFilename);
   if (m)
@@ -142,8 +142,8 @@
 /// Return LTO_READ_SUCCESS if there is no error.
 enum LTOStatus
 LTO::readLLVMObjectFile(const std::string &InputFilename,
-  NameToSymbolMap &symbols,
-  std::set &references)
+NameToSymbolMap &symbols,
+std::set &references)
 {
   Module *m = getModule(InputFilename);
   if (!m)
@@ -316,7 +316,7 @@
 
   CodeGenPasses->add(new TargetData(*Target->getTargetData()));
   Target->addPassesToEmitFile(*CodeGenPasses, Out, 
TargetMachine::AssemblyFile, 
-true);
+  true);
 
   // Run our queue of passes all at once now, efficiently.
   Passes.run(*M);
@@ -337,8 +337,10 @@
 /// Return appropriate LTOStatus.
 enum LTOStatus
 LTO::optimizeModules(const std::string &OutputFilename,
-   std::vector &exportList,
-   std::string &targetTriple)
+ std::vector &exportList,
+ std::string &targetTriple,
+ bool saveTemps,
+ const char *FinalOutputFilename)
 {
   if (modules.empty())
 return LTO_NO_WORK;
@@ -352,11 +354,15 @@
 if (theLinker.LinkModules(bigOne, modules[i], errMsg))
   return LTO_MODULE_MERGE_FAILURE;
 
-#if 0
-  // Enable this when -save-temps is used
-  std::ofstream Out("big.bc", io_mode);
-  WriteBytecodeToFile(bigOne, Out, true);
-#endif
+  sys::Path FinalOutputPath(FinalOutputFilename);
+  FinalOutputPath.eraseSuffix();
+
+  if (saveTemps) {
+std::string tempFileName(FinalOutputPath.c_str());
+tempFileName += "0.bc";
+std::ofstream Out(tempFileName.c_str(), io_mode);
+WriteBytecodeToFile(bigOne, Out, true);
+  }
 
   // Strip leading underscore because it was added to match names
   // seen by linker.
@@ -404,6 +410,13 @@
 return status;
   }
 
+  if (saveTemps) {
+std::string tempFileName(FinalOutputPath.c_str());
+tempFileName += "1.bc";
+std::ofstream Out(tempFileName.c_str(), io_mode);
+WriteBytecodeToFile(bigOne, Out, true);
+  }
+
   targetTriple = bigOne->getTargetTriple();
 
   // Run GCC to assemble and link the program into native code.



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp

2006-10-26 Thread Evan Cheng


Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.167 -> 1.168
---
Log message:

Speed up isCString()

---
Diffs of the changes:  (+14 -4)

 Constants.cpp |   18 ++
 1 files changed, 14 insertions(+), 4 deletions(-)


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.167 llvm/lib/VMCore/Constants.cpp:1.168
--- llvm/lib/VMCore/Constants.cpp:1.167 Thu Oct 26 14:15:05 2006
+++ llvm/lib/VMCore/Constants.cpp   Thu Oct 26 16:48:03 2006
@@ -1077,11 +1077,21 @@
 /// isString) and it ends in a null byte \0 and does not contains any other
 /// null bytes except its terminator.
 bool ConstantArray::isCString() const {
-  if (!isString()) return false;
-  // This is safe because a ConstantArray cannot be a zero array.
-  for (unsigned i = 0, e = getNumOperands()-1; i != e; ++i)
-if (cast(getOperand(i))->getZExtValue() == 0)
+  // Check the element type for sbyte or ubyte...
+  if (getType()->getElementType() != Type::UByteTy &&
+  getType()->getElementType() != Type::SByteTy)
+return false;
+  Constant *Zero = Constant::getNullValue(getOperand(0)->getType());
+  // Last element must be a null.
+  if (getOperand(getNumOperands()-1) != Zero)
+return false;
+  // Other elements must be non-null integers.
+  for (unsigned i = 0, e = getNumOperands()-1; i != e; ++i) {
+if (!isa(getOperand(i)))
   return false;
+if (getOperand(i) == Zero)
+  return false;
+  }
   return true;
 }
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

2006-10-26 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAG.cpp updated: 1.355 -> 1.356
---
Log message:

getPreIndexedLoad -> getIndexedLoad.

---
Diffs of the changes:  (+7 -21)

 SelectionDAG.cpp |   28 +++-
 1 files changed, 7 insertions(+), 21 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.355 
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.356
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.355Tue Oct 17 
16:47:13 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp  Thu Oct 26 16:53:40 2006
@@ -1447,28 +1447,14 @@
   return SDOperand(N, 0);
 }
 
-SDOperand SelectionDAG::getPreIndexedLoad(SDOperand OrigLoad, SDOperand Base) {
+SDOperand SelectionDAG::getIndexedLoad(SDOperand OrigLoad, SDOperand Base,
+   SDOperand Offset, ISD::MemOpAddrMode 
AM){
   LoadSDNode *LD = cast(OrigLoad);
-  SDOperand Ptr = LD->getBasePtr();
-  MVT::ValueType PtrVT = Ptr.getValueType();
-  unsigned Opc = Ptr.getOpcode();
-  SDOperand Offset = LD->getOffset();
-  assert(Offset.getOpcode() == ISD::UNDEF);
-  assert((Opc == ISD::ADD || Opc == ISD::SUB) &&
- "Load address must be !");
-  ISD::MemOpAddrMode AM = (Opc == ISD::ADD) ? ISD::PRE_INC : ISD::PRE_DEC;
-  if (Ptr.getOperand(0) == Base) {
-Offset = Ptr.getOperand(1);
-Ptr = Ptr.getOperand(0);
-  } else {
-assert(Ptr.getOperand(1) == Base);
-Offset = Ptr.getOperand(0);
-Ptr = Ptr.getOperand(1);
-  }
-
+  assert(LD->getOffset().getOpcode() == ISD::UNDEF &&
+ "Load is already a indexed load!");
   MVT::ValueType VT = OrigLoad.getValueType();
-  SDVTList VTs = getVTList(VT, PtrVT, MVT::Other);
-  SelectionDAGCSEMap::NodeID ID(ISD::LOAD, VTs, LD->getChain(), Ptr, Offset);
+  SDVTList VTs = getVTList(VT, Base.getValueType(), MVT::Other);
+  SelectionDAGCSEMap::NodeID ID(ISD::LOAD, VTs, LD->getChain(), Base, Offset);
   ID.AddInteger(AM);
   ID.AddInteger(LD->getExtensionType());
   ID.AddInteger(LD->getLoadedVT());
@@ -1479,7 +1465,7 @@
   void *IP = 0;
   if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
 return SDOperand(E, 0);
-  SDNode *N = new LoadSDNode(LD->getChain(), Ptr, Offset, AM,
+  SDNode *N = new LoadSDNode(LD->getChain(), Base, Offset, AM,
  LD->getExtensionType(), LD->getLoadedVT(),
  LD->getSrcValue(), LD->getSrcValueOffset(),
  LD->getAlignment(), LD->isVolatile());



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAG.h SelectionDAGNodes.h

2006-10-26 Thread Evan Cheng


Changes in directory llvm/include/llvm/CodeGen:

SelectionDAG.h updated: 1.139 -> 1.140
SelectionDAGNodes.h updated: 1.155 -> 1.156
---
Log message:

Indexed load / store changes.

---
Diffs of the changes:  (+18 -18)

 SelectionDAG.h  |3 ++-
 SelectionDAGNodes.h |   33 -
 2 files changed, 18 insertions(+), 18 deletions(-)


Index: llvm/include/llvm/CodeGen/SelectionDAG.h
diff -u llvm/include/llvm/CodeGen/SelectionDAG.h:1.139 
llvm/include/llvm/CodeGen/SelectionDAG.h:1.140
--- llvm/include/llvm/CodeGen/SelectionDAG.h:1.139  Tue Oct 17 16:12:56 2006
+++ llvm/include/llvm/CodeGen/SelectionDAG.hThu Oct 26 16:52:23 2006
@@ -314,7 +314,8 @@
   SDOperand getExtLoad(ISD::LoadExtType ExtType, MVT::ValueType VT,
SDOperand Chain, SDOperand Ptr, const Value *SV,
int SVOffset, MVT::ValueType EVT, bool 
isVolatile=false);
-  SDOperand getPreIndexedLoad(SDOperand OrigLoad, SDOperand Base);
+  SDOperand getIndexedLoad(SDOperand OrigLoad, SDOperand Base,
+   SDOperand Offset, ISD::MemOpAddrMode AM);
   SDOperand getVecLoad(unsigned Count, MVT::ValueType VT, SDOperand Chain, 
SDOperand Ptr, SDOperand SV);
 


Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h
diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.155 
llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.156
--- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.155 Tue Oct 17 16:12:56 2006
+++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h   Thu Oct 26 16:52:24 2006
@@ -370,9 +370,10 @@
 // operations.
 FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI,
 
-// Other operators.  LOAD and STORE have token chains as their first
-// operand, then the same operands as an LLVM load/store instruction, then 
a
-// SRCVALUE node that provides alias analysis information.
+// LOAD and STORE have token chains as their first operand, then the same
+// operands as an LLVM load/store instruction, then an offset node that
+// is added / subtracted from the base pointer to form the address (for
+// indexed memory ops).
 LOAD, STORE,
 
 // Abstract vector version of LOAD.  VLOAD has a constant element count as
@@ -529,8 +530,8 @@
   ///  load); an unindexed store does not produces a value.
   ///
   /// PRE_INC  Similar to the unindexed mode where the effective address is
-  /// PRE_DEC  the result of computation of the base pointer. However, it
-  ///  considers the computation as being folded into the load /
+  /// PRE_DEC  the value of the base pointer add / subtract the offset.
+  ///  It considers the computation as being folded into the load /
   ///  store operation (i.e. the load / store does the address
   ///  computation as well as performing the memory transaction).
   ///  The base operand is always undefined. In addition to
@@ -540,12 +541,12 @@
   ///  of the address computation).
   ///
   /// POST_INC The effective address is the value of the base pointer. The
-  /// POST_DEC value of the offset operand is then added to the base after
-  ///  memory transaction. In addition to producing a chain,
-  ///  post-indexed load produces two values (the result of the 
load
-  ///  and the result of the base + offset computation); a
-  ///  post-indexed store produces one value (the the result of the
-  ///  base + offset computation).
+  /// POST_DEC value of the offset operand is then added to / subtracted
+  ///  from the base after memory transaction. In addition to
+  ///  producing a chain, post-indexed load produces two values
+  ///  (the result of the load and the result of the base +/- 
offset
+  ///  computation); a post-indexed store produces one value (the
+  ///  the result of the base +/- offset computation).
   ///
   enum MemOpAddrMode {
 UNINDEXED = 0,
@@ -1408,9 +1409,8 @@
 : SDNode(ISD::LOAD, Chain, Ptr, Off),
   AddrMode(AM), ExtType(ETy), LoadedVT(LVT), SrcValue(SV), SVOffset(O),
   Alignment(Align), IsVolatile(Vol) {
-assert((Off.getOpcode() == ISD::UNDEF ||
-AddrMode == ISD::POST_INC || AddrMode == ISD::POST_DEC) &&
-   "Only post-indexed load has a non-undef offset operand");
+assert((Off.getOpcode() == ISD::UNDEF || AddrMode != ISD::UNINDEXED) &&
+   "Only indexed load has a non-undef offset operand");
   }
 public:
 
@@ -1462,9 +1462,8 @@
 : SDNode(ISD::STORE, Chain, Value, Ptr, Off),
   AddrMode(AM), IsTruncStore(isTrunc), StoredVT(SVT), SrcValue(SV),
   SVOffset(O), Alignment(Align), IsVolatile(Vol) {
-assert((Off.getOpcode() == ISD::UNDEF ||
-AddrMode == ISD::POST_INC || AddrMode == ISD::POST_DEC) &&
-   "Only post-indexed store has a non-undef off

[llvm-commits] CVS: llvm/lib/Target/TargetSelectionDAG.td

2006-10-26 Thread Evan Cheng


Changes in directory llvm/lib/Target:

TargetSelectionDAG.td updated: 1.73 -> 1.74
---
Log message:

Change load PatFrag to ignore indexed load.

---
Diffs of the changes:  (+62 -31)

 TargetSelectionDAG.td |   93 +-
 1 files changed, 62 insertions(+), 31 deletions(-)


Index: llvm/lib/Target/TargetSelectionDAG.td
diff -u llvm/lib/Target/TargetSelectionDAG.td:1.73 
llvm/lib/Target/TargetSelectionDAG.td:1.74
--- llvm/lib/Target/TargetSelectionDAG.td:1.73  Fri Oct 13 16:14:26 2006
+++ llvm/lib/Target/TargetSelectionDAG.td   Thu Oct 26 16:55:50 2006
@@ -399,79 +399,110 @@
 def vnot_conv : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV_bc)>;
 def ineg : PatFrag<(ops node:$in), (sub 0, node:$in)>;
 
+// load fragments.
 def load : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
-  return ISD::isNON_EXTLoad(N);
+  if (LoadSDNode *LD = dyn_cast(N))
+return LD->getExtensionType() == ISD::NON_EXTLOAD &&
+  LD->getAddressingMode() == ISD::UNINDEXED;
+  return false;
 }]>;
 
 // extending load fragments.
 def extloadi1  : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
-  if (ISD::isEXTLoad(N))
-return cast(N)->getLoadedVT() == MVT::i1;
+  if (LoadSDNode *LD = dyn_cast(N))
+return LD->getExtensionType() == ISD::EXTLOAD &&
+  LD->getAddressingMode() == ISD::UNINDEXED &&
+  LD->getLoadedVT() == MVT::i1;
   return false;
 }]>;
 def extloadi8  : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
-  if (ISD::isEXTLoad(N))
-return cast(N)->getLoadedVT() == MVT::i8;
+  if (LoadSDNode *LD = dyn_cast(N))
+return LD->getExtensionType() == ISD::EXTLOAD &&
+  LD->getAddressingMode() == ISD::UNINDEXED &&
+  LD->getLoadedVT() == MVT::i8;
   return false;
 }]>;
 def extloadi16 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
-  if (ISD::isEXTLoad(N))
-return cast(N)->getLoadedVT() == MVT::i16;
+  if (LoadSDNode *LD = dyn_cast(N))
+return LD->getExtensionType() == ISD::EXTLOAD &&
+  LD->getAddressingMode() == ISD::UNINDEXED &&
+  LD->getLoadedVT() == MVT::i16;
   return false;
 }]>;
 def extloadi32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
-  if (ISD::isEXTLoad(N))
-return cast(N)->getLoadedVT() == MVT::i32;
+  if (LoadSDNode *LD = dyn_cast(N))
+return LD->getExtensionType() == ISD::EXTLOAD &&
+  LD->getAddressingMode() == ISD::UNINDEXED &&
+  LD->getLoadedVT() == MVT::i32;
   return false;
 }]>;
 def extloadf32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
-  if (ISD::isEXTLoad(N))
-return cast(N)->getLoadedVT() == MVT::f32;
+  if (LoadSDNode *LD = dyn_cast(N))
+return LD->getExtensionType() == ISD::EXTLOAD &&
+  LD->getAddressingMode() == ISD::UNINDEXED &&
+  LD->getLoadedVT() == MVT::f32;
   return false;
 }]>;
 
-def sextloadi1 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
-  if (ISD::isSEXTLoad(N))
-return cast(N)->getLoadedVT() == MVT::i1;
+def sextloadi1  : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
+  if (LoadSDNode *LD = dyn_cast(N))
+return LD->getExtensionType() == ISD::SEXTLOAD &&
+  LD->getAddressingMode() == ISD::UNINDEXED &&
+  LD->getLoadedVT() == MVT::i1;
   return false;
 }]>;
-def sextloadi8 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
-  if (ISD::isSEXTLoad(N))
-return cast(N)->getLoadedVT() == MVT::i8;
+def sextloadi8  : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
+  if (LoadSDNode *LD = dyn_cast(N))
+return LD->getExtensionType() == ISD::SEXTLOAD &&
+  LD->getAddressingMode() == ISD::UNINDEXED &&
+  LD->getLoadedVT() == MVT::i8;
   return false;
 }]>;
 def sextloadi16 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
-  if (ISD::isSEXTLoad(N))
-return cast(N)->getLoadedVT() == MVT::i16;
+  if (LoadSDNode *LD = dyn_cast(N))
+return LD->getExtensionType() == ISD::SEXTLOAD &&
+  LD->getAddressingMode() == ISD::UNINDEXED &&
+  LD->getLoadedVT() == MVT::i16;
   return false;
 }]>;
 def sextloadi32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
-  if (ISD::isSEXTLoad(N))
-return cast(N)->getLoadedVT() == MVT::i32;
+  if (LoadSDNode *LD = dyn_cast(N))
+return LD->getExtensionType() == ISD::SEXTLOAD &&
+  LD->getAddressingMode() == ISD::UNINDEXED &&
+  LD->getLoadedVT() == MVT::i32;
   return false;
 }]>;
 
-def zextloadi1 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
-  if (ISD::isZEXTLoad(N))
-return cast(N)->getLoadedVT() == MVT::i1;
+def zextloadi1  : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
+  if (LoadSDNode *LD = dyn_cast(N))
+return LD->getExtensionType() == ISD::ZEXTLOAD &&
+  LD->getAddressingMode() == ISD::UNINDEXED &&
+  LD->getLoadedVT() == MVT::i1;
   return false;
 }]>;
-def zextloadi8 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
-  if (ISD::isZEXTLoad(N))
-return cast(N)->getLoadedVT() == MVT::i8;
+def zextloadi8  : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
+  if (LoadSDNode *LD = dyn_cast(N))
+return LD->getExtensionType() == ISD::ZEXTLOAD &&
+  LD->getAddressingMode() == ISD::UNI

[llvm-commits] patch for cfstrings

2006-10-26 Thread Chris Lattner
This improves support for the darwin-specific -fconstant-cfstrings  
option:


Index: darwin.c
===
--- darwin.c(revision 119244)
+++ darwin.c(working copy)
@@ -1379,8 +1379,28 @@ machopic_select_section (tree exp, int r
 /* APPLE LOCAL begin LLVM */
 #ifdef ENABLE_LLVM
 const char *darwin_objc_llvm_implicit_target_global_var_section(tree decl) {
+  const char *name;
+
+  if (TREE_CODE(decl) == CONST_DECL) {
+extern int flag_next_runtime;
+tree typename = TYPE_NAME(TREE_TYPE(decl));
+if (TREE_CODE(typename) == TYPE_DECL)
+  typename = DECL_NAME(typename);
+
+if (!strcmp(IDENTIFIER_POINTER(typename), "__builtin_ObjCString")) {
+  if (flag_next_runtime)
+return "__OBJC,__cstring_object,regular,no_dead_strip";
+  else
+return "__OBJC,__string_object,no_dead_strip";
+} else if (!strcmp(IDENTIFIER_POINTER(typename), "__builtin_CFString")) {
+  return "__DATA,__cfstring";
+} else {
+  return 0;
+}
+  }
+  
   /* Get a pointer to the name, past the L_OBJC_ prefix. */
-  const char *name = IDENTIFIER_POINTER (DECL_NAME (decl))+7;
+  name = IDENTIFIER_POINTER (DECL_NAME (decl))+7;
   
   if (!strncmp (name, "CLASS_METHODS_", 14))
 return "__OBJC,__cls_meth, regular, no_dead_strip";
Index: darwin.h
===
--- darwin.h(revision 119244)
+++ darwin.h(working copy)
@@ -1552,11 +1552,12 @@ void add_framework_path (char *);
  * For darwin, we have to handle all of the funny objc sections here.  Note 
that
  * doing this by name is very ugly.
  */
-#define LLVM_IMPLICIT_TARGET_GLOBAL_VAR_SECTION(decl)   \
-  ((DECL_NAME (decl) && \
-   TREE_CODE (DECL_NAME (decl)) == IDENTIFIER_NODE &&   \
-   IDENTIFIER_POINTER (DECL_NAME (decl)) && \
-   !strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "L_OBJC_", 7)) ? \
+#define LLVM_IMPLICIT_TARGET_GLOBAL_VAR_SECTION(decl)   \
+  (((DECL_NAME (decl) &&\
+TREE_CODE (DECL_NAME (decl)) == IDENTIFIER_NODE &&  \
+IDENTIFIER_POINTER (DECL_NAME (decl)) &&\
+!strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "L_OBJC_", 7)) ||  \
+   TREE_CODE(decl) == CONST_DECL) ? \
  darwin_objc_llvm_implicit_target_global_var_section(decl) : 0)
 const char *darwin_objc_llvm_implicit_target_global_var_section(tree);
 


-Chris___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp PPCTargetAsmInfo.cpp

2006-10-26 Thread Evan Cheng


Changes in directory llvm/lib/Target/PowerPC:

PPCAsmPrinter.cpp updated: 1.202 -> 1.203
PPCTargetAsmInfo.cpp updated: 1.7 -> 1.8
---
Log message:

Place cstrings in .cstring section.

---
Diffs of the changes:  (+9 -0)

 PPCAsmPrinter.cpp|8 
 PPCTargetAsmInfo.cpp |1 +
 2 files changed, 9 insertions(+)


Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.202 
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.203
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.202 Tue Oct 24 15:32:14 2006
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp   Thu Oct 26 16:48:57 2006
@@ -548,6 +548,14 @@
 O << "\t.globl " << name << "\n";
 // FALL THROUGH
   case GlobalValue::InternalLinkage:
+if (TAI->getCStringSection()) {
+  const ConstantArray *CVA = dyn_cast(C);
+  if (CVA && CVA->isCString()) {
+SwitchToDataSection(TAI->getCStringSection(), I);
+break;
+  }
+}
+
 SwitchToDataSection("\t.data", I);
 break;
   default:


Index: llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp
diff -u llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.7 
llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.8
--- llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.7Tue Oct 17 06:30:57 2006
+++ llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cppThu Oct 26 16:48:57 2006
@@ -28,6 +28,7 @@
   AlignmentIsInBytes = false;
   ConstantPoolSection = "\t.const\t";
   JumpTableDataSection = ".const";
+  CStringSection = "\t.cstring";
   LCOMMDirective = "\t.lcomm\t";
   StaticCtorsSection = ".mod_init_func";
   StaticDtorsSection = ".mod_term_func";



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/test/Regression/CodeGen/ARM/alloca.ll

2006-10-26 Thread Reid Spencer


Changes in directory llvm/test/Regression/CodeGen/ARM:

alloca.ll updated: 1.1 -> 1.2
---
Log message:

Add a run line to this test.


---
Diffs of the changes:  (+1 -0)

 alloca.ll |1 +
 1 files changed, 1 insertion(+)


Index: llvm/test/Regression/CodeGen/ARM/alloca.ll
diff -u llvm/test/Regression/CodeGen/ARM/alloca.ll:1.1 
llvm/test/Regression/CodeGen/ARM/alloca.ll:1.2
--- llvm/test/Regression/CodeGen/ARM/alloca.ll:1.1  Thu Oct 26 08:31:26 2006
+++ llvm/test/Regression/CodeGen/ARM/alloca.ll  Fri Oct 27 00:30:23 2006
@@ -1,3 +1,4 @@
+; RUN: llvm-as < %s | llc -march=arm
 void %f(uint %a) {
 entry:
%tmp1032 = alloca ubyte, uint %a



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits