Re: [llvm-commits] CVS: llvm/lib/Target/X86/X86Subtarget.cpp X86Subtarget.h X86TargetMachine.cpp

2006-12-20 Thread Evan Cheng
Ok. I see PPC does exactly the same thing. But this seems like a  
temporary solution. Could we add some kind of JIT relocation model  
which are target specific? Or any method that would allow llc to  
codegen (by specifying some command line option?) in the exact same  
way as the JIT would?

Evan
On Dec 19, 2006, at 9:59 PM, Chris Lattner wrote:

> On Dec 19, 2006, at 9:46 PM, Evan Cheng wrote:
>> Let me clarify. It's important for llc and lli to behave exactly the
>> same up to the final code emission pass. With your patch, the two
>> would behave differently and that means we can no longer use llc to
>> reproduce jit codegen bug.
>
> PPC64 has a similar problem.  It wants to do codegen in PIC mode,  
> but it doesn't want the JIT to make dyld stubs.  As such, it does  
> 'JIT PIC' mode, which is like PIC but doesn't do the extra load to  
> go through dyld stubs.
>
> An alternative approach would be to have the JIT synthesize dyld  
> stubs, but that takes work to implement and yields slower programs.
>
> -Chris
>
>

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


Re: [llvm-commits] CVS: llvm/lib/Target/X86/X86Subtarget.cpp X86Subtarget.h X86TargetMachine.cpp

2006-12-20 Thread Reid Spencer
On Wed, 2006-12-20 at 00:25 -0800, Evan Cheng wrote:
> Ok. I see PPC does exactly the same thing. But this seems like a  
> temporary solution. Could we add some kind of JIT relocation model  
> which are target specific? Or any method that would allow llc to  
> codegen (by specifying some command line option?) in the exact same  
> way as the JIT would?

Having debugged a number of JIT failures now, I'll throw in my $0.02
worth that we *must* retain this functionality. Sometimes the
only/best/easiest way to find a JIT bug is by generating code with llc
and looking at it. There needs to be a way to ensure/force JIT and LLC
to produce identical code (as far as possible).

Reid.

> 
> Evan
> On Dec 19, 2006, at 9:59 PM, Chris Lattner wrote:
> 
> > On Dec 19, 2006, at 9:46 PM, Evan Cheng wrote:
> >> Let me clarify. It's important for llc and lli to behave exactly the
> >> same up to the final code emission pass. With your patch, the two
> >> would behave differently and that means we can no longer use llc to
> >> reproduce jit codegen bug.
> >
> > PPC64 has a similar problem.  It wants to do codegen in PIC mode,  
> > but it doesn't want the JIT to make dyld stubs.  As such, it does  
> > 'JIT PIC' mode, which is like PIC but doesn't do the extra load to  
> > go through dyld stubs.
> >
> > An alternative approach would be to have the JIT synthesize dyld  
> > stubs, but that takes work to implement and yields slower programs.
> >
> > -Chris
> >
> >
> 
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

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


Re: [llvm-commits] CVS: llvm/lib/Target/X86/X86Subtarget.cpp X86Subtarget.h X86TargetMachine.cpp

2006-12-20 Thread Anton Korobeynikov
Hello, Evan.

> Ok. I see PPC does exactly the same thing. But this seems like a  
> temporary solution. Could we add some kind of JIT relocation model  
> which are target specific? Or any method that would allow llc to  
> codegen (by specifying some command line option?) in the exact same  
> way as the JIT would?
Well, probably yes. There is only 1 variable controlling codegen
behaviour in x86 subtarget.

-- 
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


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


Re: [llvm-commits] CVS: llvm/lib/Target/X86/X86Subtarget.cpp X86Subtarget.h X86TargetMachine.cpp

2006-12-20 Thread Anton Korobeynikov
Hello, Chris.

> PPC64 has a similar problem.  It wants to do codegen in PIC mode, but  
> it doesn't want the JIT to make dyld stubs.  As such, it does 'JIT  
> PIC' mode, which is like PIC but doesn't do the extra load to go  
> through dyld stubs.

Yes, It's quite the same. At codegen level we know only addres of import
table entry, which will be filled by system loader with correct address
of symbol. Thus, we need to perform extra load in order to get this
address runtime.
When we get address of symbol during JIT via libSystem we know *exact*
address, so, we don't need any extra load. So, in general, dllimported
GVs are just ordinary externals in JIT mode.

-- 
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


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


[llvm-commits] [llvm-commit][llvm-gcc]Select powerpc cpu based on gcc arguments, not tuning settings.

2006-12-20 Thread Jim Laskey

Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 121533)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -136,6 +136,10 @@
/* Target cpu type */
+/* APPLE LOCAL begin LLVM */
+const char *rs6000_cpu_target = "ppc";
+/* APPLE LOCAL end LLVM */
+
enum processor_type rs6000_cpu;
struct rs6000_cpu_select rs6000_select[3] =
{
@@ -1324,6 +1328,10 @@
   rs6000_select[0].string = default_cpu;
   rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 :  
PROCESSOR_DEFAULT;

+  /* APPLE LOCAL begin LLVM */
+  rs6000_cpu_target = TARGET_POWERPC64 ? "ppc64" : "ppc";
+  /* APPLE LOCAL end LLVM */
+
   /* APPLE LOCAL begin -fast */
   if (flag_fast || flag_fastf || flag_fastcp)
   {
@@ -1355,6 +1363,10 @@
/* APPLE LOCAL begin -fast */
mcpu_cpu = processor_target_table[j].processor;
/* APPLE LOCAL end -fast */
+
+   /* APPLE LOCAL begin LLVM */
+rs6000_cpu_target = processor_target_table[j].name;
+   /* APPLE LOCAL end LLVM */
  }
break;
  }
Index: gcc/config/rs6000/rs6000.h
===
--- gcc/config/rs6000/rs6000.h  (revision 121533)
+++ gcc/config/rs6000/rs6000.h  (working copy)
@@ -408,6 +408,10 @@
PROCESSOR_POWER5
};
+/* APPLE LOCAL begin LLVM */
+extern const char *rs6000_cpu_target;
+/* APPLE LOCAL end LLVM */
+
extern enum processor_type rs6000_cpu;
/* Recast the processor type to the cpu attribute.  */
@@ -3610,27 +3614,8 @@
/* Turn -march=xx into a CPU type.
  */
#define LLVM_SET_SUBTARGET_FEATURES(F) \
-  { switch (rs6000_cpu) { \
-case PROCESSOR_RIOS1: \
-case PROCESSOR_RIOS2: \
-case PROCESSOR_MPCCORE: \
-case PROCESSOR_PPC403: \
-case PROCESSOR_PPC405: \
-case PROCESSOR_PPC440: F.setCPU("ppc"); break; \
-case PROCESSOR_PPC601: F.setCPU("601"); break; \
-case PROCESSOR_PPC603: F.setCPU("603"); break; \
-case PROCESSOR_PPC604: F.setCPU("604"); break; \
-case PROCESSOR_PPC604e: F.setCPU("604e"); break; \
-case PROCESSOR_PPC620: \
-case PROCESSOR_PPC630: F.setCPU("620"); break; \
-case PROCESSOR_PPC750: F.setCPU("750"); break; \
-case PROCESSOR_PPC7400: F.setCPU("7400"); break; \
-case PROCESSOR_PPC7450: F.setCPU("7450"); break; \
-case PROCESSOR_PPC8540: F.setCPU("7450"); break; \
-case PROCESSOR_RS64A: F.setCPU("ppc64"); break; \
-case PROCESSOR_POWER4: \
-case PROCESSOR_POWER5: F.setCPU("970"); break; /* FIXME: NOT  
RIGHT */ \

-} \
+  { \
+F.setCPU(rs6000_cpu_target); \
 F.AddFeature("altivec", TARGET_ALTIVEC); \
 F.AddFeature("gpul", TARGET_MFCRF); \
 F.AddFeature("fsqrt", TARGET_PPC_GPOPT); \



smime.p7s
Description: S/MIME cryptographic signature
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y

2006-12-20 Thread Reid Spencer


Changes in directory llvm/lib/AsmParser:

llvmAsmParser.y updated: 1.289 -> 1.290
---
Log message:

Allow negative constants for unsigned integers and unsigned constants 
greater than MAX_INT64 for signed integers. This is now valid and is just
waiting for the distinction between signed and unsigned to go away.


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

 llvmAsmParser.y |   24 +---
 1 files changed, 13 insertions(+), 11 deletions(-)


Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.289 
llvm/lib/AsmParser/llvmAsmParser.y:1.290
--- llvm/lib/AsmParser/llvmAsmParser.y:1.289Fri Dec  8 12:06:15 2006
+++ llvm/lib/AsmParser/llvmAsmParser.y  Wed Dec 20 11:20:09 2006
@@ -926,7 +926,6 @@
 
 // EUINT64VAL - A positive number within uns. long long range
 %token  EUINT64VAL
-%type   EINT64VAL
 
 %token SINTVAL   // Signed 32 bit ints...
 %token UINTVAL   // Unsigned 32 bit ints...
@@ -995,15 +994,6 @@
   CHECK_FOR_ERROR
 };
 
-
-EINT64VAL : ESINT64VAL;  // These have same type and can't cause 
problems...
-EINT64VAL : EUINT64VAL {
-  if ($1 > (uint64_t)INT64_MAX) // Outside of my range!
-GEN_ERROR("Value too large for type!");
-  $$ = (int64_t)$1;
-  CHECK_FOR_ERROR
-};
-
 // Operations that are notably excluded from this list include:
 // RET, BR, & SWITCH because they end basic blocks and are treated specially.
 //
@@ -1486,7 +1476,13 @@
 delete $1;
 CHECK_FOR_ERROR
   }
-  | SIntType EINT64VAL {  // integral constants
+  | SIntType ESINT64VAL {  // integral constants
+if (!ConstantInt::isValueValidForType($1, $2))
+  GEN_ERROR("Constant value doesn't fit in type!");
+$$ = ConstantInt::get($1, $2);
+CHECK_FOR_ERROR
+  }
+  | SIntType EUINT64VAL {  // integral constants
 if (!ConstantInt::isValueValidForType($1, $2))
   GEN_ERROR("Constant value doesn't fit in type!");
 $$ = ConstantInt::get($1, $2);
@@ -1498,6 +1494,12 @@
 $$ = ConstantInt::get($1, $2);
 CHECK_FOR_ERROR
   }
+  | UIntType ESINT64VAL {
+if (!ConstantInt::isValueValidForType($1, $2))
+  GEN_ERROR("Constant value doesn't fit in type!");
+$$ = ConstantInt::get($1, $2);
+CHECK_FOR_ERROR
+  }
   | BOOL TRUETOK {  // Boolean constants
 $$ = ConstantBool::getTrue();
 CHECK_FOR_ERROR



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


Re: [llvm-commits] CVS: llvm/lib/Target/X86/X86Subtarget.cpp X86Subtarget.h X86TargetMachine.cpp

2006-12-20 Thread Evan Cheng
I took a look at mingw related code. It seems to me for mingw that  
you can set relocation type to pic for llc and static for jit. No?  
Then GVRequiresExtraLoad can just check relocation type?

Also GVRequiresExtraLoad now violates 80-col policy and its style is  
inconsistent with the rest of the llvm code. Please fix it.

bool foo()
{
}

vs.

bool foo() {
}

Thanks,

Evan

On Dec 20, 2006, at 2:31 AM, Anton Korobeynikov wrote:

> Hello, Chris.
>
>> PPC64 has a similar problem.  It wants to do codegen in PIC mode, but
>> it doesn't want the JIT to make dyld stubs.  As such, it does 'JIT
>> PIC' mode, which is like PIC but doesn't do the extra load to go
>> through dyld stubs.
>
> Yes, It's quite the same. At codegen level we know only addres of  
> import
> table entry, which will be filled by system loader with correct  
> address
> of symbol. Thus, we need to perform extra load in order to get this
> address runtime.
> When we get address of symbol during JIT via libSystem we know *exact*
> address, so, we don't need any extra load. So, in general, dllimported
> GVs are just ordinary externals in JIT mode.
>
> -- 
> With best regards, Anton Korobeynikov.
>
> Faculty of Mathematics & Mechanics, Saint Petersburg State University.
>
>

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


[llvm-commits] CVS: llvm/test/Feature/testconstants.ll

2006-12-20 Thread Reid Spencer


Changes in directory llvm/test/Feature:

testconstants.ll updated: 1.7 -> 1.8
---
Log message:

Add some tests for negative constants to unsigned and large positive
constants to signed.


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

 testconstants.ll |7 +++
 1 files changed, 7 insertions(+)


Index: llvm/test/Feature/testconstants.ll
diff -u llvm/test/Feature/testconstants.ll:1.7 
llvm/test/Feature/testconstants.ll:1.8
--- llvm/test/Feature/testconstants.ll:1.7  Fri Dec  1 22:23:07 2006
+++ llvm/test/Feature/testconstants.ll  Wed Dec 20 11:27:58 2006
@@ -24,3 +24,10 @@
ret sbyte* null; Test null
 end
 
+uint %negativeUnsigned() {
+ret uint -1
+}
+
+int %largeSigned() {
+   ret int 39
+}



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


Re: [llvm-commits] CVS: llvm/lib/Target/X86/X86Subtarget.cpp X86Subtarget.h X86TargetMachine.cpp

2006-12-20 Thread Chris Lattner
On Dec 20, 2006, at 12:25 AM, Evan Cheng wrote:
> Ok. I see PPC does exactly the same thing. But this seems like a  
> temporary solution. Could we add some kind of JIT relocation model  
> which are target specific? Or any method that would allow llc to  
> codegen (by specifying some command line option?) in the exact same  
> way as the JIT would?

I'm not opposed to adding -relocation-model=jit.  It sounds like the  
best solution for PPC64, but I agree with Evan that it sounds like  
relo=static should work for mingw.

-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/Pass.h

2006-12-20 Thread Devang Patel


Changes in directory llvm/include/llvm:

Pass.h updated: 1.63 -> 1.64
---
Log message:

Enable old pass manager. New pass manager causes CBE failures in llvm-test.


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

 Pass.h |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/include/llvm/Pass.h
diff -u llvm/include/llvm/Pass.h:1.63 llvm/include/llvm/Pass.h:1.64
--- llvm/include/llvm/Pass.h:1.63   Tue Dec 19 15:32:24 2006
+++ llvm/include/llvm/Pass.hWed Dec 20 13:57:07 2006
@@ -36,7 +36,7 @@
 #include 
 #include 
 
-//#define USE_OLD_PASSMANAGER 1
+#define USE_OLD_PASSMANAGER 1
 
 namespace llvm {
 



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


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

2006-12-20 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Verifier.cpp updated: 1.176 -> 1.177
---
Log message:

Revert the previous patch which was incorrect.  This unbreaks eon, but rebreaks
invoke-1.ll


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

 Verifier.cpp |3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)


Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.176 llvm/lib/VMCore/Verifier.cpp:1.177
--- llvm/lib/VMCore/Verifier.cpp:1.176  Mon Dec 18 17:40:19 2006
+++ llvm/lib/VMCore/Verifier.cppWed Dec 20 13:50:15 2006
@@ -921,7 +921,8 @@
 // If it is used by something non-phi, then the other case is that
 // 'OpBlock' dominates all of its predecessors other than the
 // invoke.  In this case, the invoke value can still be used.
-if (!Bad) {
+if (Bad) {
+  Bad = false;
   for (pred_iterator PI = pred_begin(OpBlock),
E = pred_end(OpBlock); PI != E; ++PI) {
 if (*PI != II->getParent() && !EF->dominates(OpBlock, *PI)) {



___
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/X86Subtarget.cpp

2006-12-20 Thread Anton Korobeynikov


Changes in directory llvm/lib/Target/X86:

X86Subtarget.cpp updated: 1.44 -> 1.45
---
Log message:

Fixed 80 cols & style violation


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

 X86Subtarget.cpp |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)


Index: llvm/lib/Target/X86/X86Subtarget.cpp
diff -u llvm/lib/Target/X86/X86Subtarget.cpp:1.44 
llvm/lib/Target/X86/X86Subtarget.cpp:1.45
--- llvm/lib/Target/X86/X86Subtarget.cpp:1.44   Tue Dec 19 19:03:20 2006
+++ llvm/lib/Target/X86/X86Subtarget.cppWed Dec 20 14:40:30 2006
@@ -30,7 +30,8 @@
 /// symbols are indirect, loading the value at address GV rather then the
 /// value of GV itself. This means that the GlobalAddress must be in the base
 /// or index register of the address, not the GV offset field.
-bool X86Subtarget::GVRequiresExtraLoad(const GlobalValue* GV, bool 
isDirectCall) const
+bool X86Subtarget::GVRequiresExtraLoad(const GlobalValue* GV,
+   bool isDirectCall) const
 {
   if (GenerateExtraLoadsForGVs)
 if (isTargetDarwin()) {
@@ -209,7 +210,8 @@
 
 /// SetJITMode - This is called to inform the subtarget info that we are
 /// producing code for the JIT.
-void X86Subtarget::SetJITMode() {
+void X86Subtarget::SetJITMode()
+{
   // JIT mode doesn't want extra loads for dllimported symbols, it knows 
exactly
   // where everything is.
   if (isTargetCygwin())



___
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

2006-12-20 Thread Jim Laskey


Changes in directory llvm/lib/Target/PowerPC:

PPCAsmPrinter.cpp updated: 1.223 -> 1.224
---
Log message:

Changes to target powerpc for non-Darwin assemblers.

1. Patches from Nick Lewycky.
2. Code to filter register names and print them as numeric values on
non-Darwin systems.


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

 PPCAsmPrinter.cpp |   72 ++
 1 files changed, 62 insertions(+), 10 deletions(-)


Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.223 
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.224
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.223 Tue Dec 19 16:59:26 2006
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp   Wed Dec 20 14:56:46 2006
@@ -86,12 +86,66 @@
 
 void printMachineInstruction(const MachineInstr *MI);
 void printOp(const MachineOperand &MO);
+
+/// stripRegisterPrefix - This method strips the character prefix from a
+/// register name so that only the number is left.  Used by for linux asm.
+void stripRegisterPrefix(std::string &Name) {
+  // Potential prefixes.
+  static const char *Prefixes[] = { "r", "f", "v", "cr" };
+  unsigned NPrefixes = sizeof(Prefixes) / sizeof(const char *);
+  // Fetch string length.
+  unsigned Size = Name.size();
+  // Start position of numeric portion.
+  unsigned Pos = 0;
+  
+  // Try each prefix.
+  for (unsigned i = 0; i < NPrefixes; ++i) {
+const char *Prefix = Prefixes[i];
+unsigned Length = strlen(Prefix);
+// Does it match the beginning?
+if (Name.compare(0, Length, Prefix, Length) == 0) {
+  // If so, start looking beyond the prefix.
+  Pos = strlen(Prefix);
+  break;
+}
+  }
+  
+   // If we have a match.
+  if (Pos) {
+// Remaining characters better be digits.
+for (unsigned j = Pos; j < Size; ++j) {
+  unsigned Ch = Name[j];
+  if (Ch < '0' || '9' < Ch) return;
+}
+
+// Pass back just the numeric portion.
+Name = Name.substr(Pos, Size - Pos);
+  }
+}
+
+/// printRegister - Print register according to target requirements.
+///
+void printRegister(const MachineOperand &MO, bool R0AsZero) {
+  unsigned RegNo = MO.getReg();
+  assert(MRegisterInfo::isPhysicalRegister(RegNo) && "Not physreg??");
+  
+  // If we should use 0 for R0.
+  if (R0AsZero && RegNo == PPC::R0) {
+O << "0";
+return;
+  }
+  
+  std::string Name = TM.getRegisterInfo()->get(RegNo).Name;
+  // Linux assembler (Others?) does not take register mnemonics.
+  // FIXME - What about special registers used in mfspr/mtspr?
+  if (!Subtarget.isDarwin()) stripRegisterPrefix(Name);
+  O << Name;
+}
 
 void printOperand(const MachineInstr *MI, unsigned OpNo) {
   const MachineOperand &MO = MI->getOperand(OpNo);
   if (MO.isRegister()) {
-assert(MRegisterInfo::isPhysicalRegister(MO.getReg())&&"Not 
physreg??");
-O << TM.getRegisterInfo()->get(MO.getReg()).Name;
+printRegister(MO, false);
   } else if (MO.isImmediate()) {
 O << MO.getImmedValue();
   } else {
@@ -239,10 +293,7 @@
   // the value contained in the register.  For this reason, the darwin
   // assembler requires that we print r0 as 0 (no r) when used as the base.
   const MachineOperand &MO = MI->getOperand(OpNo);
-  if (MO.getReg() == PPC::R0)
-O << '0';
-  else
-O << TM.getRegisterInfo()->get(MO.getReg()).Name;
+  printRegister(MO, true);
   O << ", ";
   printOperand(MI, OpNo+1);
 }
@@ -616,7 +667,7 @@
 SwitchToDataSection("\t.data", I);
 O << ".comm " << name << "," << Size;
   }
-  O << "\t\t; '" << I->getName() << "'\n";
+  O << "\t\t" << TAI->getCommentString() << " '" << I->getName() << "'\n";
 } else {
   switch (I->getLinkage()) {
   case GlobalValue::LinkOnceLinkage:
@@ -649,7 +700,8 @@
   }
 
   EmitAlignment(Align, I);
-  O << name << ":\t\t\t\t; '" << I->getName() << "'\n";
+  O << name << ":\t\t\t\t" << TAI->getCommentString() << " '"
+<< I->getName() << "'\n";
 
   // If the initializer is a extern weak symbol, remember to emit the weak
   // reference!
@@ -751,8 +803,8 @@
 
 
 
-/// createDarwinCodePrinterPass - Returns a pass that prints the PPC assembly
-/// code for a MachineFunction to the given output stream, in a format that the
+/// createPPCAsmPrinterPass - Returns a pass that prints the PPC assembly code
+/// for a MachineFunction to the given output stream, in a format that the
 /// Darwin assembler can deal with.
 ///
 FunctionPass *llvm::createPPCAsmPrinterPass(std::ostream &o,



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

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

2006-12-20 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Verifier.cpp updated: 1.177 -> 1.178
---
Log message:

Fix Regression/Verifier/invoke-1.ll


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

 Verifier.cpp |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)


Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.177 llvm/lib/VMCore/Verifier.cpp:1.178
--- llvm/lib/VMCore/Verifier.cpp:1.177  Wed Dec 20 13:50:15 2006
+++ llvm/lib/VMCore/Verifier.cppWed Dec 20 15:20:13 2006
@@ -902,6 +902,10 @@
 if (InvokeInst *II = dyn_cast(Op)) {
   OpBlock = II->getNormalDest();
   
+  Assert2(OpBlock != II->getUnwindDest(),
+  "No uses of invoke possible due to dominance structure!",
+  Op, II);
+  
   // If the normal successor of an invoke instruction has multiple
   // predecessors, then the normal edge from the invoke is critical, so
   // the invoke value can only be live if the destination block
@@ -931,8 +935,9 @@
 }
   }
 }
-Assert1(!Bad,
-"Invoke value defined on critical edge but not dead!", &I);
+Assert2(!Bad,
+"Invoke value defined on critical edge but not dead!", &I,
+Op);
   }
 } else if (OpBlock == BB) {
   // If they are in the same basic block, make sure that the definition



___
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

2006-12-20 Thread Jim Laskey


Changes in directory llvm/lib/Target/PowerPC:

PPCAsmPrinter.cpp updated: 1.224 -> 1.225
---
Log message:

Original patch was overly complicated.



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

 PPCAsmPrinter.cpp |   45 +++--
 1 files changed, 11 insertions(+), 34 deletions(-)


Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.224 
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.225
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.224 Wed Dec 20 14:56:46 2006
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp   Wed Dec 20 15:33:34 2006
@@ -89,38 +89,15 @@
 
 /// stripRegisterPrefix - This method strips the character prefix from a
 /// register name so that only the number is left.  Used by for linux asm.
-void stripRegisterPrefix(std::string &Name) {
-  // Potential prefixes.
-  static const char *Prefixes[] = { "r", "f", "v", "cr" };
-  unsigned NPrefixes = sizeof(Prefixes) / sizeof(const char *);
-  // Fetch string length.
-  unsigned Size = Name.size();
-  // Start position of numeric portion.
-  unsigned Pos = 0;
-  
-  // Try each prefix.
-  for (unsigned i = 0; i < NPrefixes; ++i) {
-const char *Prefix = Prefixes[i];
-unsigned Length = strlen(Prefix);
-// Does it match the beginning?
-if (Name.compare(0, Length, Prefix, Length) == 0) {
-  // If so, start looking beyond the prefix.
-  Pos = strlen(Prefix);
-  break;
-}
-  }
-  
-   // If we have a match.
-  if (Pos) {
-// Remaining characters better be digits.
-for (unsigned j = Pos; j < Size; ++j) {
-  unsigned Ch = Name[j];
-  if (Ch < '0' || '9' < Ch) return;
-}
-
-// Pass back just the numeric portion.
-Name = Name.substr(Pos, Size - Pos);
+const char *stripRegisterPrefix(const char *RegName) {
+  switch (RegName[0]) {
+  case 'r':
+  case 'f':
+  case 'v': return RegName + 1;
+  case 'c': if (RegName[0] == 'r') return RegName + 2;
   }
+   
+  return RegName;
 }
 
 /// printRegister - Print register according to target requirements.
@@ -135,11 +112,11 @@
 return;
   }
   
-  std::string Name = TM.getRegisterInfo()->get(RegNo).Name;
+  const char *RegName = TM.getRegisterInfo()->get(RegNo).Name;
   // Linux assembler (Others?) does not take register mnemonics.
   // FIXME - What about special registers used in mfspr/mtspr?
-  if (!Subtarget.isDarwin()) stripRegisterPrefix(Name);
-  O << Name;
+  if (!Subtarget.isDarwin()) RegName = stripRegisterPrefix(RegName);
+  O << RegName;
 }
 
 void printOperand(const MachineInstr *MI, unsigned OpNo) {



___
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

2006-12-20 Thread Jim Laskey


Changes in directory llvm/lib/Target/PowerPC:

PPCAsmPrinter.cpp updated: 1.225 -> 1.226
---
Log message:

Oops.


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

 PPCAsmPrinter.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.225 
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.226
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.225 Wed Dec 20 15:33:34 2006
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp   Wed Dec 20 15:35:00 2006
@@ -94,7 +94,7 @@
   case 'r':
   case 'f':
   case 'v': return RegName + 1;
-  case 'c': if (RegName[0] == 'r') return RegName + 2;
+  case 'c': if (RegName[1] == 'r') return RegName + 2;
   }

   return RegName;



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


[llvm-commits] [llvm-gcc] CastFixes To Make llvm-convert.cpp nearly signless (Review & Commit)

2006-12-20 Thread Reid Spencer
All,

The attached patch removes all but one isSigned() calls from
llvm-convert.cpp and otherwise makes it signless. This cleans up the
casting patch committed yesterday and bases signedness only on
TYPE_UNSIGNED(TREE_TYPE(tree)). The one exception can't be removed until
the signed and unsigned integer types are unified.

Although I've tested this extensively and it causes no regressions, it
needs to be reviewed. In particular, in two places I have changed
casts-to-bool into SetCondInst to prevent "trunc to bool" semantics
which could break things. 

Some things to note:

1. EmitAsScalarType was just another name for a CastToType and had
exactly one use
   so I just removed it and replaced its call with a CastToType call.
2. I've added several CastToXXType functions near the beginning of the
file to
   assist with casting int<->int, fp<->fp, and any<->any. This just
prevents a
   little opcode selection logic from being sprinkled throughout the
source.
3. Most of the changes to llvm-types.cpp is just wrapping long lines. I
noticed it
   so figured I'd fix it.
4. I added a tree typed argument to HandleScalarArgument so the
signedness
   can be derived. This isn't always used, but its the only accurate way
to get
   the signedness in a couple cases where it is used. If 0 is passed in,
it
   defaults to unsigned.
5. In two places (1787 and 2516) I removed some casting. These were
remnants from 
   the SHIFT patch. Since shift no longer cares about the sign of its
operands, 
   there's no need to cast them to force a particular kind of shift.
6. The NOOPCastToType function is a misnomer. The casts it produces are
often
   not BitCast (the only "noop" cast we have). It can do integer
conversions and
   Ptr<->Int as well. I couldn't think of a better name for this so I
just left it.
7. The rest of the changes are of two forms: (a) change a cast to use a
specific
   cast opcode, or (b) change a cast to use an opcode derived from 
   CastInst::getCastOpcode and the signedness information from the gcc
tree
   available.

One small step towards signlessness.

Reid.
Index: gcc/llvm-abi.h
===
--- gcc/llvm-abi.h	(revision 230)
+++ gcc/llvm-abi.h	(working copy)
@@ -64,7 +64,7 @@
   
   /// HandleScalarArgument - This is the primary callback that specifies an LLVM
   /// argument to pass.
-  void HandleScalarArgument(const llvm::Type *LLVMTy) {}
+  void HandleScalarArgument(const llvm::Type *LLVMTy, tree argTreeType) {}
   
   /// EnterField - Called when we're about the enter the field of a struct
   /// or union.  FieldNo is the number of the element we are entering in the
@@ -191,9 +191,9 @@
 const Type *Ty = ConvertType(type);
 
 if (TREE_ADDRESSABLE(type)) {// Constructible object, pass by-ref
-  C.HandleScalarArgument(PointerType::get(Ty));
+  C.HandleScalarArgument(PointerType::get(Ty), type);
 } else if (Ty->isFirstClassType()) {
-  C.HandleScalarArgument(Ty);
+  C.HandleScalarArgument(Ty, type);
 } else if (LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS(type)) {
   PassInIntegerRegisters(type, Ty);
 } else if (TREE_CODE(type) == RECORD_TYPE) {
@@ -289,10 +289,10 @@
 
 for (unsigned i = 0, e = Elts.size(); i != e; ++i) {
   C.EnterField(i, STy);
-  C.HandleScalarArgument(Elts[i]);
+  C.HandleScalarArgument(Elts[i], 0);
   C.ExitField();
 }
-  } 
+  }
 };
 
 /// TheLLVMABI - This can be defined by targets if they want total control over
Index: gcc/llvm-convert.cpp
===
--- gcc/llvm-convert.cpp	(revision 230)
+++ gcc/llvm-convert.cpp	(working copy)
@@ -206,7 +206,7 @@
   ++AI;
 }
 
-void HandleScalarArgument(const llvm::Type *LLVMTy) {
+void HandleScalarArgument(const llvm::Type *LLVMTy, tree type) {
   Value *ArgVal = AI;
   if (ArgVal->getType() != LLVMTy) {
 // If this is just a mismatch between integer types, this could be due
@@ -214,10 +214,9 @@
 // the actual impls is a short or char.
 assert(ArgVal->getType()->isIntegral() && LLVMTy->isIntegral() &&
"Lowerings don't match?");
-Instruction::CastOps opcode = CastInst::getCastOpcode(
-ArgVal, ArgVal->getType()->isSigned(), LLVMTy, LLVMTy->isSigned());
-ArgVal = 
-  CastInst::create(opcode, ArgVal, LLVMTy, NameStack.back(), CurBB);
+bool isSigned = type == 0 ? true : !TYPE_UNSIGNED(type);
+ArgVal = CastInst::createIntegerCast(ArgVal, LLVMTy, isSigned,
+ NameStack.back(), CurBB);
   }
   assert(!LocStack.empty());
   Value *Loc = LocStack.back();
@@ -424,14 +423,19 @@
 if (!isAggregateTreeType(TREE_TYPE(DECL_RESULT(FnDecl {
   // If the DECL_RESULT is a scalar type, just load out the return value
   // and return it.
-  RetVal = new LoadInst(DECL_LLVM(DECL_RESULT(FnDecl)), "retval",

[llvm-commits] CVS: llvm/test/Regression/CodeGen/PowerPC/2006-04-05-splat-ish.ll Frames-align.ll Frames-alloca.ll Frames-large.ll Frames-small.ll fsqrt.ll seteq-0.ll stfiwx.ll

2006-12-20 Thread Jim Laskey


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

2006-04-05-splat-ish.ll updated: 1.2 -> 1.3
Frames-align.ll updated: 1.2 -> 1.3
Frames-alloca.ll updated: 1.2 -> 1.3
Frames-large.ll updated: 1.3 -> 1.4
Frames-small.ll updated: 1.3 -> 1.4
fsqrt.ll updated: 1.3 -> 1.4
seteq-0.ll updated: 1.2 -> 1.3
stfiwx.ll updated: 1.2 -> 1.3
---
Log message:

These tests all rely on using register mnemonics and thus must behave in the
world of darwin.


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

 2006-04-05-splat-ish.ll |2 +-
 Frames-align.ll |6 +++---
 Frames-alloca.ll|   32 
 Frames-large.ll |   48 
 Frames-small.ll |   32 
 fsqrt.ll|8 
 seteq-0.ll  |2 +-
 stfiwx.ll   |8 
 8 files changed, 69 insertions(+), 69 deletions(-)


Index: llvm/test/Regression/CodeGen/PowerPC/2006-04-05-splat-ish.ll
diff -u llvm/test/Regression/CodeGen/PowerPC/2006-04-05-splat-ish.ll:1.2 
llvm/test/Regression/CodeGen/PowerPC/2006-04-05-splat-ish.ll:1.3
--- llvm/test/Regression/CodeGen/PowerPC/2006-04-05-splat-ish.ll:1.2Fri Dec 
 1 22:23:08 2006
+++ llvm/test/Regression/CodeGen/PowerPC/2006-04-05-splat-ish.llWed Dec 
20 18:01:42 2006
@@ -1,4 +1,4 @@
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 -mcpu=g5 | grep 
'vspltish v.*, 10'
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 
-mtriple=powerpc-apple-darwin8 -mcpu=g5 | grep 'vspltish v.*, 10'
 
 void %test(<8 x short>* %P) {
%tmp = load <8 x short>* %P ; <<8 x short>> [#uses=1]


Index: llvm/test/Regression/CodeGen/PowerPC/Frames-align.ll
diff -u llvm/test/Regression/CodeGen/PowerPC/Frames-align.ll:1.2 
llvm/test/Regression/CodeGen/PowerPC/Frames-align.ll:1.3
--- llvm/test/Regression/CodeGen/PowerPC/Frames-align.ll:1.2Fri Dec  1 
22:23:08 2006
+++ llvm/test/Regression/CodeGen/PowerPC/Frames-align.llWed Dec 20 
18:01:42 2006
@@ -1,6 +1,6 @@
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 | grep 'rlwinm r0, r1, 
0, 22, 31' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 | grep 'subfic r0, r0, 
-17408' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc64 | grep 'rldicl r0, r1, 
0, 54'
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 
-mtriple=powerpc-apple-darwin8 | grep 'rlwinm r0, r1, 0, 22, 31' &&
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 
-mtriple=powerpc-apple-darwin8 | grep 'subfic r0, r0, -17408' &&
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc64 
-mtriple=powerpc-apple-darwin8 | grep 'rldicl r0, r1, 0, 54'
 
 
 implementation


Index: llvm/test/Regression/CodeGen/PowerPC/Frames-alloca.ll
diff -u llvm/test/Regression/CodeGen/PowerPC/Frames-alloca.ll:1.2 
llvm/test/Regression/CodeGen/PowerPC/Frames-alloca.ll:1.3
--- llvm/test/Regression/CodeGen/PowerPC/Frames-alloca.ll:1.2   Fri Dec  1 
22:23:08 2006
+++ llvm/test/Regression/CodeGen/PowerPC/Frames-alloca.ll   Wed Dec 20 
18:01:42 2006
@@ -1,19 +1,19 @@
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 | grep 'stw r31, 20(r1)' 
&&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 | grep 'stwu r1, 
-64(r1)' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 | grep 'lwz r1, 0(r1)' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 | grep 'lwz r31, 20(r1)' 
&&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 -disable-fp-elim | grep 
'stw r31, 20(r1)' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 -disable-fp-elim | grep 
'stwu r1, -64(r1)' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 -disable-fp-elim | grep 
'lwz r1, 0(r1)' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 -disable-fp-elim | grep 
'lwz r31, 20(r1)' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc64 | grep 'std r31, 40(r1)' 
&&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc64 | grep 'stdu r1, 
-112(r1)' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc64 | grep 'ld r1, 0(r1)' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc64 | grep 'ld r31, 40(r1)' 
&&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc64 -disable-fp-elim | grep 
'std r31, 40(r1)' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc64 -disable-fp-elim | grep 
'stdu r1, -112(r1)' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc64 -disable-fp-elim | grep 
'ld r1, 0(r1)' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc64 -disable-fp-elim | grep 
'ld r31, 40(r1)'
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 
-mtriple=powerpc-apple-darwin8 | grep 'stw r31, 20(r1)' &&
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 
-mtriple=powerpc-apple-darwin8 | grep 'stwu r1, -64(r1)' &&
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 
-mtriple=powerpc-apple-darwin8 | grep 'lwz r1, 0(r1)' &&
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 
-mtriple=powerpc-apple-d

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

2006-12-20 Thread Devang Patel


Changes in directory llvm/lib/VMCore:

PassManager.cpp updated: 1.109 -> 1.110
---
Log message:

At the beginning of run, initialize analyis info availability for _ALL_
pass managers. Otherwise, stale available analysis info, from the managers not
yet run, may cause pass manager to take wrong turn.

This fixes CBE test failures reported by nightly tester.


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

 PassManager.cpp |   24 +++-
 1 files changed, 19 insertions(+), 5 deletions(-)


Index: llvm/lib/VMCore/PassManager.cpp
diff -u llvm/lib/VMCore/PassManager.cpp:1.109 
llvm/lib/VMCore/PassManager.cpp:1.110
--- llvm/lib/VMCore/PassManager.cpp:1.109   Tue Dec 19 14:12:38 2006
+++ llvm/lib/VMCore/PassManager.cpp Wed Dec 20 18:16:50 2006
@@ -189,6 +189,8 @@
   void dumpPasses() const;
   void dumpArguments() const;
 
+  void initializeAllAnalysisInfo();
+
 protected:
   
   /// Collection of pass managers
@@ -773,6 +775,21 @@
   cerr << "\n";
 }
 
+void PMTopLevelManager::initializeAllAnalysisInfo() {
+  
+  for (std::vector::iterator I = PassManagers.begin(),
+ E = PassManagers.end(); I != E; ++I) {
+PMDataManager *PMD = dynamic_cast(*I);
+assert(PMD && "This is not a PassManager");
+PMD->initializeAnalysisInfo();
+  }
+  
+  // Initailize other pass managers
+  for (std::vector::iterator I = IndirectPassManagers.begin(),
+ E = IndirectPassManagers.end(); I != E; ++I)
+(*I)->initializeAnalysisInfo();
+}
+
 
//===--===//
 // PMDataManager implementation
 
@@ -1051,7 +1068,6 @@
 return false;
 
   bool Changed = doInitialization(F);
-  initializeAnalysisInfo();
 
   std::string Msg1 = "Executing Pass '";
   std::string Msg3 = "' Made Modification '";
@@ -1240,6 +1256,7 @@
   dumpArguments();
   dumpPasses();
 
+  initializeAllAnalysisInfo();
   for (unsigned Index = 0; Index < getNumContainedManagers(); ++Index) {  
 FPPassManager *FP = getContainedManager(Index);
 Changed |= FP->runOnFunction(F);
@@ -1322,8 +1339,6 @@
   if (F.isExternal())
 return false;
 
-  initializeAnalysisInfo();
-
   std::string Msg1 = "Executing Pass '";
   std::string Msg3 = "' Made Modification '";
 
@@ -1357,7 +1372,6 @@
 bool FPPassManager::runOnModule(Module &M) {
 
   bool Changed = doInitialization(M);
-  initializeAnalysisInfo();
 
   for(Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
 this->runOnFunction(*I);
@@ -1462,7 +1476,6 @@
 bool
 MPPassManager::runOnModule(Module &M) {
   bool Changed = false;
-  initializeAnalysisInfo();
 
   std::string Msg1 = "Executing Pass '";
   std::string Msg3 = "' Made Modification '";
@@ -1528,6 +1541,7 @@
   dumpArguments();
   dumpPasses();
 
+  initializeAllAnalysisInfo();
   for (unsigned Index = 0; Index < getNumContainedManagers(); ++Index) {  
 MPPassManager *MP = getContainedManager(Index);
 Changed |= MP->runOnModule(M);



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


[llvm-commits] [llvm-gcc] Removal of signedness from gcc/config/i386/i386.h

2006-12-20 Thread Reid Spencer
The attached patch removes signedness from the i386.h file, in
particular the LLVM_TARGET_INTRINSIC_LOWER macro. The macro takes three
additional arguments and depends on a change in the function its called
from, like this:

Index: gcc/llvm-convert.cpp
===
--- gcc/llvm-convert.cpp(revision 230)
+++ gcc/llvm-convert.cpp(working copy)
@@ -3011,9 +3090,11 @@
   for (tree args = TREE_OPERAND(exp, 1); args; args = TREE_CHAIN(args))
 Operands.push_back(Emit(TREE_VALUE(args), 0));

+  bool ResIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_TYPE(fndecl)));
+  bool ExpIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp));
   unsigned FnCode = DECL_FUNCTION_CODE(fndecl);
-  LLVM_TARGET_INTRINSIC_LOWER(FnCode, DestLoc, Result,
-  ResultType, Operands, CurBB);
+  LLVM_TARGET_INTRINSIC_LOWER(FnCode, DestLoc, Result, ResultType,
Operands,
+  CurBB, exp, ResIsSigned, ExpIsSigned);
 #endif
   return false;
 }

This allows the macro to make signedness determinations based on the gcc
tree codes.

Although this patch removes isSigned() calls and is correct, it is not
optimal. It is still using CastInst::getCastOpcode to figure out the
casting opcode for it. Perhaps someone with a little more knowledge of
the intrinsic functions could narrow these down to the appropriate cast
opcode.

Please review and commit when you can.

Reid.

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


Re: [llvm-commits] [llvm-gcc] Removal of signedness from gcc/config/i386/i386.h

2006-12-20 Thread Reid Spencer
(this email actually has the patch attached)

The attached patch removes signedness from the i386.h file, in
particular the LLVM_TARGET_INTRINSIC_LOWER macro. The macro takes three
additional arguments and depends on a change in the function its called
from, like this:

Index: gcc/llvm-convert.cpp
===
--- gcc/llvm-convert.cpp(revision 230)
+++ gcc/llvm-convert.cpp(working copy)
@@ -3011,9 +3090,11 @@
   for (tree args = TREE_OPERAND(exp, 1); args; args = TREE_CHAIN(args))
 Operands.push_back(Emit(TREE_VALUE(args), 0));

+  bool ResIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_TYPE(fndecl)));
+  bool ExpIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp));
   unsigned FnCode = DECL_FUNCTION_CODE(fndecl);
-  LLVM_TARGET_INTRINSIC_LOWER(FnCode, DestLoc, Result,
-  ResultType, Operands, CurBB);
+  LLVM_TARGET_INTRINSIC_LOWER(FnCode, DestLoc, Result, ResultType,
Operands,
+  CurBB, exp, ResIsSigned, ExpIsSigned);
 #endif
   return false;
 }

This allows the macro to make signedness determinations based on the gcc
tree codes.

Although this patch removes isSigned() calls and is correct, it is not
optimal. It is still using CastInst::getCastOpcode to figure out the
casting opcode for it. Perhaps someone with a little more knowledge of
the intrinsic functions could narrow these down to the appropriate cast
opcode.

Please review and commit when you can.

Reid.
Index: gcc/llvm-convert.cpp
===
--- gcc/llvm-convert.cpp	(revision 230)
+++ gcc/llvm-convert.cpp	(working copy)
@@ -3011,9 +3090,11 @@
   for (tree args = TREE_OPERAND(exp, 1); args; args = TREE_CHAIN(args))
 Operands.push_back(Emit(TREE_VALUE(args), 0));
   
+  bool ResIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_TYPE(fndecl)));
+  bool ExpIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp));
   unsigned FnCode = DECL_FUNCTION_CODE(fndecl);
-  LLVM_TARGET_INTRINSIC_LOWER(FnCode, DestLoc, Result, 
-  ResultType, Operands, CurBB);
+  LLVM_TARGET_INTRINSIC_LOWER(FnCode, DestLoc, Result, ResultType, Operands, 
+  CurBB, exp, ResIsSigned, ExpIsSigned);
 #endif
   return false;
 }
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm-gcc] Signedness patch for rs6000.h

2006-12-20 Thread Reid Spencer
Attached is a patch for the gcc/config/rs6000/rs6000.h file to remove
isSigned() calls. This is analgous to the last patch I sent but for PPC
instead of X86.  Same comments
apply.

This patch has not been compiled or tested as I don't have a PPC
machine. Please review and try it.

Reid.
Index: gcc/config/rs6000/rs6000.h
===
--- gcc/config/rs6000/rs6000.h	(revision 230)
+++ gcc/config/rs6000/rs6000.h	(working copy)
@@ -3700,6 +3700,27 @@
((TY == Type::SByteTy) ? 'b' :   \
 ((TY == Type::FloatTy) ? 'f' : 'x'
   
+/* LLVM_TARGET_INTRINSIC_CAST_RESULT - This macro just provides a frequently
+ * used sequence for use inside LLVM_TARGET_INTRINSIC_LOWER. Note that this
+ * macro assumes it is being invoked from inside LLVM_TARGET_INTRINSC_LOWER
+ * (see below) because it requires the "ResIsSigned" and "ExpIsSigned" macro 
+ * arguments in order to derive signedness for the cast.
+ */
+#define LLVM_TARGET_INTRINSIC_CAST_RESULT(RESULT, RESISSIGNED, DESTTY,\
+  EXPISSIGNED)\
+  { Instruction::CastOps opcode = CastInst::getCastOpcode(RESULT, \
+RESISSIGNED, DESTTY, EXPISSIGNED);\
+RESULT = CastInst::create(opcode, RESULT, DESTTY, "tmp", CurBB);  \
+  } 
+
+/* LLVM_INTRINSIC_OP_IS_SIGNED - This macro determines if a given operand
+ * to the intrinsic is signed or not. Note that this macro assumes it is being
+ * invoked from inside LLVM_TARGET_INTRINSIC_LOWER (see below) because it 
+ * requires the "exp" macro argument in order to determine signedness
+ */
+#define LLVM_INTRINSIC_OP_IS_SIGNED(EXP, OPNUM) \
+  !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(EXP, (OPNUM+1
+
 /* LLVM_TARGET_INTRINSIC_LOWER - For builtins that we want to expand to normal
  * LLVM code, emit the code now.  If we can handle the code, this macro should
  * emit the code, return true.  Note that this would be much better as a
@@ -3854,22 +3875,22 @@
 } \
 return false; \
   case ALTIVEC_BUILTIN_VPKUHUM: { \
-Instruction::CastOps opc = CastInst::getCastOpcode(   \
-OPS[0], OPS[0]->getType()->isSigned(), DESTTY, DESTTY->isSigned());   \
+Instruction::CastOps opc = CastInst::getCastOpcode(OPS[0],\
+LLVM_INTRINSIC_OP_IS_SIGNED(EXP,0), DESTTY, EXPISSIGNED); \
 OPS[0] = CastInst::create(opc, OPS[0], DESTTY, OPS[0]->getName(), CurBB); \
-opc = CastInst::getCastOpcode(\
-OPS[1], OPS[1]->getType()->isSigned(), DESTTY, DESTTY->isSigned());   \
+opc = CastInst::getCastOpcode(OPS[1], \
+LLVM_INTRINSIC_OP_IS_SIGNED(EXP,1), DESTTY, EXPISSIGNED); \
 OPS[1] = CastInst::create(opc, OPS[1], DESTTY, OPS[0]->getName(), CurBB); \
 RESULT = BuildVectorShuffle(OPS[0], OPS[1], 1, 3, 5, 7, 9, 11, 13, 15,\
 17, 19, 21, 23, 25, 27, 29, 31);  \
 return true;  \
   }   \
   case ALTIVEC_BUILTIN_VPKUWUM: { \
-Instruction::CastOps opc = CastInst::getCastOpcode(   \
-OPS[0], OPS[0]->getType()->isSigned(), DESTTY, DESTTY->isSigned());   \
+Instruction::CastOps opc = CastInst::getCastOpcode(OPS[0],\
+LLVM_INTRINSIC_OP_IS_SIGNED(EXP,0), DESTTY, EXPISSIGNED); \
 OPS[0] = CastInst::create(opc, OPS[0], DESTTY, OPS[0]->getName(), CurBB); \
-opc = CastInst::getCastOpcode(\
-OPS[1], OPS[1]->getType()->isSigned(), DESTTY, DESTTY->isSigned());   \
+opc = CastInst::getCastOpcode(OPS[1]  \
+LLVM_INTRINSIC_OP_IS_SIGNED(EXP,1), DESTTY, EXPISSIGNED): \
 OPS[1] = CastInst::create(opc, OPS[1], DESTTY, OPS[0]->getName(), CurBB); \
 RESULT = BuildVectorShuffle(OPS[0], OPS[1], 1, 3, 5, 7, 9, 11, 13, 15);   \
 return true;  \
@@ -3903,9 +3924,7 @@
 Constant *C = ConstantInt::get(Type::IntTy, 0x7FFF);  \
 C = ConstantPacked::get(std::vector(4, C));\
 RESULT = BinaryOperator::createAnd(OPS[0], C, "tmp", CurBB);  \
-Instruction::CastOps opcode = CastInst::getCastOpcode(\
-RESULT, RESULT->getType()->isSigned(), DESTTY, DESTTY->isSigned());   \
-RESULT = CastInst::create(opcode, RESULT, DESTTY

[llvm-commits] ppc linux patch 3

2006-12-20 Thread Nick Lewycky
This is the last patch, adding the LinuxAsmPrinter and
LinuxTargetAsmInfo. Most of the code is a copy of the DarwinAsmPrinter.

Nick Lewycky
Index: lib/Target/PowerPC/PPCAsmPrinter.cpp
===
RCS file: /var/cvs/llvm/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp,v
retrieving revision 1.226
diff -u -r1.226 PPCAsmPrinter.cpp
--- lib/Target/PowerPC/PPCAsmPrinter.cpp	20 Dec 2006 21:35:00 -	1.226
+++ lib/Target/PowerPC/PPCAsmPrinter.cpp	21 Dec 2006 01:12:31 -
@@ -282,6 +282,35 @@
 virtual bool doFinalization(Module &M) = 0;
   };
 
+  /// LinuxAsmPrinter - PowerPC assembly printer, customized for Linux
+  struct VISIBILITY_HIDDEN LinuxAsmPrinter : public PPCAsmPrinter {
+
+DwarfWriter DW;
+
+LinuxAsmPrinter(std::ostream &O, PPCTargetMachine &TM,
+const TargetAsmInfo *T)
+  : PPCAsmPrinter(O, TM, T), DW(O, this, T) {
+}
+
+virtual const char *getPassName() const {
+  return "Linux PPC Assembly Printer";
+}
+
+bool runOnMachineFunction(MachineFunction &F);
+bool doInitialization(Module &M);
+bool doFinalization(Module &M);
+
+void getAnalysisUsage(AnalysisUsage &AU) const {
+  AU.setPreservesAll();
+  AU.addRequired();
+  PPCAsmPrinter::getAnalysisUsage(AU);
+}
+
+/// getSectionForFunction - Return the section that we should emit the
+/// specified function body into.
+virtual std::string getSectionForFunction(const Function &F) const;
+  };
+
   /// DarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac OS
   /// X
   struct VISIBILITY_HIDDEN DarwinAsmPrinter : public PPCAsmPrinter {
@@ -491,7 +520,270 @@
   return;
 }
 
+/// runOnMachineFunction - This uses the printMachineInstruction()
+/// method to print assembly for each instruction.
+///
+bool LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
+  DW.SetDebugInfo(&getAnalysis());
+
+  SetupMachineFunction(MF);
+  O << "\n\n";
+  
+  // Print out constants referenced by the function
+  EmitConstantPool(MF.getConstantPool());
+
+  // Print out labels for the function.
+  const Function *F = MF.getFunction();
+  SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
+  
+  switch (F->getLinkage()) {
+  default: assert(0 && "Unknown linkage type!");
+  case Function::InternalLinkage:  // Symbols default to internal.
+break;
+  case Function::ExternalLinkage:
+O << "\t.global\t" << CurrentFnName << '\n'
+  << "\t.type\t" << CurrentFnName << ", @function\n";
+break;
+  case Function::WeakLinkage:
+  case Function::LinkOnceLinkage:
+O << "\t.global\t" << CurrentFnName << '\n';
+O << "\t.weak\t" << CurrentFnName << '\n';
+break;
+  }
+  EmitAlignment(2, F);
+  O << CurrentFnName << ":\n";
+
+  // Emit pre-function debug information.
+  DW.BeginFunction(&MF);
+
+  // Print out code for the function.
+  for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
+   I != E; ++I) {
+// Print a label for the basic block.
+if (I != MF.begin()) {
+  printBasicBlockLabel(I, true);
+  O << '\n';
+}
+for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
+ II != E; ++II) {
+  // Print the assembly for the instruction.
+  O << "\t";
+  printMachineInstruction(II);
+}
+  }
+
+  O << "\t.size\t" << CurrentFnName << ",.-" << CurrentFnName << "\n";
+
+  // Print out jump tables referenced by the function.
+  EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
+  
+  // Emit post-function debug information.
+  DW.EndFunction();
+  
+  // We didn't modify anything.
+  return false;
+}
+
+bool LinuxAsmPrinter::doInitialization(Module &M) {
+  AsmPrinter::doInitialization(M);
+  
+  // GNU as handles section names wrapped in quotes
+  Mang->setUseQuotes(true);
+
+  SwitchToTextSection(TAI->getTextSection());
+  
+  // Emit initial debug information.
+  DW.BeginModule(&M);
+  return false;
+}
+
+bool LinuxAsmPrinter::doFinalization(Module &M) {
+  const TargetData *TD = TM.getTargetData();
 
+  // Print out module-level global variables here.
+  for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
+   I != E; ++I) {
+if (!I->hasInitializer()) continue;   // External global require no code
+
+// Check to see if this is a special global used by LLVM, if so, emit it.
+if (EmitSpecialLLVMGlobal(I))
+  continue;
+
+std::string name = Mang->getValueName(I);
+Constant *C = I->getInitializer();
+unsigned Size = TD->getTypeSize(C->getType());
+unsigned Align = TD->getPreferredAlignmentLog(I);
+
+if (C->isNullValue() && /* FIXME: Verify correct */
+(I->hasInternalLinkage() || I->hasWeakLinkage() ||
+ I->hasLinkOnceLinkage() ||
+ (I->hasExternalLinkage() && !I->hasSection( {
+  if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
+  if (I->hasExternalLinkage()) {
+O << "\t.global " 

[llvm-commits] ppc linux patch 3.1

2006-12-20 Thread Nick Lewycky
The original patch had a merge error and wouldn't compile. This one has
been fixed. As well, a large #if 0 has been replaced with a simple
"TODO" comment.

Nick
Index: lib/Target/PowerPC/PPCAsmPrinter.cpp
===
RCS file: /var/cvs/llvm/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp,v
retrieving revision 1.226
diff -u -r1.226 PPCAsmPrinter.cpp
--- lib/Target/PowerPC/PPCAsmPrinter.cpp	20 Dec 2006 21:35:00 -	1.226
+++ lib/Target/PowerPC/PPCAsmPrinter.cpp	21 Dec 2006 01:19:14 -
@@ -282,6 +282,35 @@
 virtual bool doFinalization(Module &M) = 0;
   };
 
+  /// LinuxAsmPrinter - PowerPC assembly printer, customized for Linux
+  struct VISIBILITY_HIDDEN LinuxAsmPrinter : public PPCAsmPrinter {
+
+DwarfWriter DW;
+
+LinuxAsmPrinter(std::ostream &O, PPCTargetMachine &TM,
+const TargetAsmInfo *T)
+  : PPCAsmPrinter(O, TM, T), DW(O, this, T) {
+}
+
+virtual const char *getPassName() const {
+  return "Linux PPC Assembly Printer";
+}
+
+bool runOnMachineFunction(MachineFunction &F);
+bool doInitialization(Module &M);
+bool doFinalization(Module &M);
+
+void getAnalysisUsage(AnalysisUsage &AU) const {
+  AU.setPreservesAll();
+  AU.addRequired();
+  PPCAsmPrinter::getAnalysisUsage(AU);
+}
+
+/// getSectionForFunction - Return the section that we should emit the
+/// specified function body into.
+virtual std::string getSectionForFunction(const Function &F) const;
+  };
+
   /// DarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac OS
   /// X
   struct VISIBILITY_HIDDEN DarwinAsmPrinter : public PPCAsmPrinter {
@@ -491,7 +520,194 @@
   return;
 }
 
+/// runOnMachineFunction - This uses the printMachineInstruction()
+/// method to print assembly for each instruction.
+///
+bool LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
+  DW.SetDebugInfo(&getAnalysis());
+
+  SetupMachineFunction(MF);
+  O << "\n\n";
+  
+  // Print out constants referenced by the function
+  EmitConstantPool(MF.getConstantPool());
+
+  // Print out labels for the function.
+  const Function *F = MF.getFunction();
+  SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
+  
+  switch (F->getLinkage()) {
+  default: assert(0 && "Unknown linkage type!");
+  case Function::InternalLinkage:  // Symbols default to internal.
+break;
+  case Function::ExternalLinkage:
+O << "\t.global\t" << CurrentFnName << '\n'
+  << "\t.type\t" << CurrentFnName << ", @function\n";
+break;
+  case Function::WeakLinkage:
+  case Function::LinkOnceLinkage:
+O << "\t.global\t" << CurrentFnName << '\n';
+O << "\t.weak\t" << CurrentFnName << '\n';
+break;
+  }
+  EmitAlignment(2, F);
+  O << CurrentFnName << ":\n";
+
+  // Emit pre-function debug information.
+  DW.BeginFunction(&MF);
+
+  // Print out code for the function.
+  for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
+   I != E; ++I) {
+// Print a label for the basic block.
+if (I != MF.begin()) {
+  printBasicBlockLabel(I, true);
+  O << '\n';
+}
+for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
+ II != E; ++II) {
+  // Print the assembly for the instruction.
+  O << "\t";
+  printMachineInstruction(II);
+}
+  }
+
+  O << "\t.size\t" << CurrentFnName << ",.-" << CurrentFnName << "\n";
+
+  // Print out jump tables referenced by the function.
+  EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
+  
+  // Emit post-function debug information.
+  DW.EndFunction();
+  
+  // We didn't modify anything.
+  return false;
+}
+
+bool LinuxAsmPrinter::doInitialization(Module &M) {
+  AsmPrinter::doInitialization(M);
+  
+  // GNU as handles section names wrapped in quotes
+  Mang->setUseQuotes(true);
+
+  SwitchToTextSection(TAI->getTextSection());
+  
+  // Emit initial debug information.
+  DW.BeginModule(&M);
+  return false;
+}
+
+bool LinuxAsmPrinter::doFinalization(Module &M) {
+  const TargetData *TD = TM.getTargetData();
 
+  // Print out module-level global variables here.
+  for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
+   I != E; ++I) {
+if (!I->hasInitializer()) continue;   // External global require no code
+
+// Check to see if this is a special global used by LLVM, if so, emit it.
+if (EmitSpecialLLVMGlobal(I))
+  continue;
+
+std::string name = Mang->getValueName(I);
+Constant *C = I->getInitializer();
+unsigned Size = TD->getTypeSize(C->getType());
+unsigned Align = TD->getPreferredAlignmentLog(I);
+
+if (C->isNullValue() && /* FIXME: Verify correct */
+(I->hasInternalLinkage() || I->hasWeakLinkage() ||
+ I->hasLinkOnceLinkage() ||
+ (I->hasExternalLinkage() && !I->hasSection( {
+  if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
+  if (I->hasExternalLinkage()) {
+  

Re: [llvm-commits] [llvm-gcc] CastFixes To Make llvm-convert.cpp nearly signless (Review & Commit)

2006-12-20 Thread Chris Lattner
On Dec 20, 2006, at 3:13 PM, Reid Spencer wrote:
> The attached patch removes all but one isSigned() calls from
> llvm-convert.cpp and otherwise makes it signless. This cleans up the
> casting patch committed yesterday and bases signedness only on
> TYPE_UNSIGNED(TREE_TYPE(tree)). The one exception can't be removed  
> until
> the signed and unsigned integer types are unified.

Woot.

> Although I've tested this extensively and it causes no regressions, it
> needs to be reviewed. In particular, in two places I have changed
> casts-to-bool into SetCondInst to prevent "trunc to bool" semantics
> which could break things.

Ok.

> Some things to note:
>
> 1. EmitAsScalarType was just another name for a CastToType and had
> exactly one use
>so I just removed it and replaced its call with a CastToType call.

Ok.  However, please change this:

@@ -1314,9 +1366,11 @@
  Value *TreeToLLVM::EmitCOND_EXPR(tree exp) {
+  // Emit the conditional expression and trunc/bitcast to BoolTy
+  Value *Cond = Emit(COND_EXPR_COND(exp), 0);
+  Cond = new SetCondInst(Instruction::SetNE, Cond,
+ Constant::getNullValue(Cond->getType()),  
"toBool",
+ CurBB);
tree Then = COND_EXPR_THEN(exp);
tree Else = COND_EXPR_ELSE(exp);

... to only make the setne instruction if Cond->getType() !=  
Type::BoolTy.  It is common for the predicate to be bool, so we  
should avoid the extraneous instruction if so.

  Value *TreeToLLVM::EmitTRUTH_NOT_EXPR(tree exp) {
Value *V = Emit(TREE_OPERAND(exp, 0), 0);
+  V = new SetCondInst(Instruction::SetNE, V,
+  Constant::getNullValue(V->getType()),  
"toBool", CurBB);
V = BinaryOperator::createNot(V, V->getName()+"not", CurBB);
+  return CastToUIntType(V, ConvertType(TREE_TYPE(exp)));
  }

Likewise.

Likewise in TreeToLLVM::EmitTruthOp.

> 2. I've added several CastToXXType functions near the beginning of the
> file to
>assist with casting int<->int, fp<->fp, and any<->any. This just
> prevents a
>little opcode selection logic from being sprinkled throughout the
> source.

Ok.  Please rename CastToIntType -> CastToSIntType to make it  
explicit it is signed.

In CastToFPType, if srcbits == dstbits, just return V.



> 3. Most of the changes to llvm-types.cpp is just wrapping long  
> lines. I
> noticed it
>so figured I'd fix it.



> 4. I added a tree typed argument to HandleScalarArgument so the  
> signedness
>can be derived. This isn't always used, but its the only  
> accurate way to get
>the signedness in a couple cases where it is used. If 0 is  
> passed in, it
>defaults to unsigned.

Are you sure?  The code looks like it handles null as signed:

===
--- gcc/llvm-convert.cpp(revision 230)
+++ gcc/llvm-convert.cpp(working copy)
@@ -214,10 +214,9 @@
  // the actual impls is a short or char.
  assert(ArgVal->getType()->isIntegral() && LLVMTy->isIntegral 
() &&
 "Lowerings don't match?");
-Instruction::CastOps opcode = CastInst::getCastOpcode(
-ArgVal, ArgVal->getType()->isSigned(), LLVMTy, LLVMTy- 
 >isSigned());
-ArgVal =
-  CastInst::create(opcode, ArgVal, LLVMTy, NameStack.back(),  
CurBB);
+bool isSigned = type == 0 ? true : !TYPE_UNSIGNED(type);
+ArgVal = CastInst::createIntegerCast(ArgVal, LLVMTy, isSigned,
+ NameStack.back(), CurBB);



> 5. In two places (1787 and 2516) I removed some casting. These were
> remnants from
>the SHIFT patch. Since shift no longer cares about the sign of its
> operands,
>there's no need to cast them to force a particular kind of shift.

Great.

> 6. The NOOPCastToType function is a misnomer. The casts it produces  
> are
> often
>not BitCast (the only "noop" cast we have). It can do integer
> conversions and
>Ptr<->Int as well. I couldn't think of a better name for this so I
> just left it.

The only place where you call NOOPCastToType without a bitcast  
operand is in the "@@ -2475,8 +2544,18 @@" hunk of the patch.  Why  
not just change that the call CastToType, and change the rest to not  
pass bitcast?

While you're at it, you could rename NOOPCastToType to  
BitCastToType.  You can change "CastToType(BitCast, ...)" calls to  
call BitCastToType instead.

Doing this will also eliminate the call to isNoopCast (the ctor for  
bitcast does the check), which makes it dead.

> 7. The rest of the changes are of two forms: (a) change a cast to  
> use a
> specific
>cast opcode, or (b) change a cast to use an opcode derived from
>CastInst::getCastOpcode and the signedness information from the gcc
> tree
>available.

This code (EmitLV_ARRAY_REF):

@@ -3832,7 +3917,7 @@
IndexVal->getType() != Type::UIntTy &&
IndexVal->getType() != Type::LongTy &&
IndexVal->getType() != Type::ULongTy)
-IndexVal = CastToTy

Re: [llvm-commits] [llvm-gcc] Signedness patch for rs6000.h

2006-12-20 Thread Chris Lattner

On Dec 20, 2006, at 4:46 PM, Reid Spencer wrote:

> Attached is a patch for the gcc/config/rs6000/rs6000.h file to remove
> isSigned() calls. This is analgous to the last patch I sent but for  
> PPC
> instead of X86.  Same comments
> apply.
>
> This patch has not been compiled or tested as I don't have a PPC
> machine. Please review and try it.

This patch looks fine to me.

Jim, please check that it works (e.g. by making a testcase that uses  
the modified instructions) and commit it if it looks good to you,

Thanks,

-Chris

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


Re: [llvm-commits] [llvm-gcc] Removal of signedness from gcc/config/i386/i386.h

2006-12-20 Thread Chris Lattner
Is there a change to i386.h that goes along with this?

-Chris

On Dec 20, 2006, at 4:34 PM, Reid Spencer wrote:

> (this email actually has the patch attached)
>
> The attached patch removes signedness from the i386.h file, in
> particular the LLVM_TARGET_INTRINSIC_LOWER macro. The macro takes  
> three
> additional arguments and depends on a change in the function its  
> called
> from, like this:
>
> Index: gcc/llvm-convert.cpp
> ===
> --- gcc/llvm-convert.cpp(revision 230)
> +++ gcc/llvm-convert.cpp(working copy)
> @@ -3011,9 +3090,11 @@
>for (tree args = TREE_OPERAND(exp, 1); args; args = TREE_CHAIN 
> (args))
>  Operands.push_back(Emit(TREE_VALUE(args), 0));
>
> +  bool ResIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_TYPE(fndecl)));
> +  bool ExpIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp));
>unsigned FnCode = DECL_FUNCTION_CODE(fndecl);
> -  LLVM_TARGET_INTRINSIC_LOWER(FnCode, DestLoc, Result,
> -  ResultType, Operands, CurBB);
> +  LLVM_TARGET_INTRINSIC_LOWER(FnCode, DestLoc, Result, ResultType,
> Operands,
> +  CurBB, exp, ResIsSigned, ExpIsSigned);
>  #endif
>return false;
>  }
>
> This allows the macro to make signedness determinations based on  
> the gcc
> tree codes.
>
> Although this patch removes isSigned() calls and is correct, it is not
> optimal. It is still using CastInst::getCastOpcode to figure out the
> casting opcode for it. Perhaps someone with a little more knowledge of
> the intrinsic functions could narrow these down to the appropriate  
> cast
> opcode.
>
> Please review and commit when you can.
>
> Reid.
> 
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

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


Re: [llvm-commits] [llvm-gcc] Signedness patch for rs6000.h

2006-12-20 Thread Reid Spencer
Jim,

Don't commit that!

These patches are intertwined. After everything is reviewed, I'll submit
the whole thing as one patch.  If you commit this, it will break on
i386.

Reid.

On Wed, 2006-12-20 at 17:43 -0800, Chris Lattner wrote:
> On Dec 20, 2006, at 4:46 PM, Reid Spencer wrote:
> 
> > Attached is a patch for the gcc/config/rs6000/rs6000.h file to remove
> > isSigned() calls. This is analgous to the last patch I sent but for  
> > PPC
> > instead of X86.  Same comments
> > apply.
> >
> > This patch has not been compiled or tested as I don't have a PPC
> > machine. Please review and try it.
> 
> This patch looks fine to me.
> 
> Jim, please check that it works (e.g. by making a testcase that uses  
> the modified instructions) and commit it if it looks good to you,
> 
> Thanks,
> 
> -Chris
> 

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


Re: [llvm-commits] [llvm-gcc] Removal of signedness from gcc/config/i386/i386.h

2006-12-20 Thread Reid Spencer
Okay, one more time ..

On Wed, 2006-12-20 at 16:34 -0800, Reid Spencer wrote:
> (this email actually has the patch attached)
> 
> The attached patch removes signedness from the i386.h file, in
> particular the LLVM_TARGET_INTRINSIC_LOWER macro. The macro takes three
> additional arguments and depends on a change in the function its called
> from, like this:
> 
> Index: gcc/llvm-convert.cpp
> ===
> --- gcc/llvm-convert.cpp(revision 230)
> +++ gcc/llvm-convert.cpp(working copy)
> @@ -3011,9 +3090,11 @@
>for (tree args = TREE_OPERAND(exp, 1); args; args = TREE_CHAIN(args))
>  Operands.push_back(Emit(TREE_VALUE(args), 0));
> 
> +  bool ResIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_TYPE(fndecl)));
> +  bool ExpIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp));
>unsigned FnCode = DECL_FUNCTION_CODE(fndecl);
> -  LLVM_TARGET_INTRINSIC_LOWER(FnCode, DestLoc, Result,
> -  ResultType, Operands, CurBB);
> +  LLVM_TARGET_INTRINSIC_LOWER(FnCode, DestLoc, Result, ResultType,
> Operands,
> +  CurBB, exp, ResIsSigned, ExpIsSigned);
>  #endif
>return false;
>  }
> 
> This allows the macro to make signedness determinations based on the gcc
> tree codes.
> 
> Although this patch removes isSigned() calls and is correct, it is not
> optimal. It is still using CastInst::getCastOpcode to figure out the
> casting opcode for it. Perhaps someone with a little more knowledge of
> the intrinsic functions could narrow these down to the appropriate cast
> opcode.
> 
> Please review and commit when you can.
> 
> Reid.
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Index: gcc/config/i386/i386.h
===
--- gcc/config/i386/i386.h	(revision 230)
+++ gcc/config/i386/i386.h	(working copy)
@@ -4044,6 +4044,27 @@
 #define LLVM_OVERRIDE_TARGET_ARCH() \
   (TARGET_64BIT ? "x86_64" : "")
 
+/* LLVM_TARGET_INTRINSIC_CAST_RESULT - This macro just provides a frequently
+ * used sequence for use inside LLVM_TARGET_INTRINSIC_LOWER. Note that this
+ * macro assumes it is being invoked from inside LLVM_TARGET_INTRINSC_LOWER
+ * (see below) because it requires the "ResIsSigned" and "ExpIsSigned" macro 
+ * arguments in order to derive signedness for the cast.
+ */
+#define LLVM_TARGET_INTRINSIC_CAST_RESULT(RESULT, RESISSIGNED, DESTTY,\
+  EXPISSIGNED)\
+  { Instruction::CastOps opcode = CastInst::getCastOpcode(RESULT, \
+RESISSIGNED, DESTTY, EXPISSIGNED);\
+RESULT = CastInst::create(opcode, RESULT, DESTTY, "tmp", CurBB);  \
+  } 
+
+/* LLVM_INTRINSIC_OP_IS_SIGNED - This macro determines if a given operand
+ * to the intrinsic is signed or not. Note that this macro assumes it is being
+ * invoked from inside LLVM_TARGET_INTRINSIC_LOWER (see below) because it 
+ * requires the "exp" macro argument in order to determine signedness
+ */
+#define LLVM_INTRINSIC_OP_IS_SIGNED(EXP, OPNUM) \
+  !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(EXP, (OPNUM+1
+
 /* LLVM_TARGET_INTRINSIC_LOWER - For builtins that we want to expand to normal
  * LLVM code, emit the code now.  If we can handle the code, this macro should
  * emit the code, return true.  Note that this would be much better as a
@@ -4052,7 +4073,8 @@
  * use methods it defines.
  */
 #define LLVM_TARGET_INTRINSIC_LOWER(BUILTIN_CODE, DESTLOC, RESULT,\
-DESTTY, OPS, CURBB)   \
+DESTTY, OPS, CURBB, EXP, RESISSIGNED, \
+EXPISSIGNED)  \
   switch (BUILTIN_CODE) { \
   default: break; \
   case IX86_BUILTIN_ADDPS:\
@@ -4088,9 +4110,7 @@
 Value *Undef = UndefValue::get(Type::IntTy);  \
 OPS[1] = BuildVector(OPS[1], Undef, Undef, Undef, NULL);  \
 RESULT = new CallInst(psllw, OPS[0], OPS[1], "tmp", CurBB);   \
-Instruction::CastOps opcode = CastInst::getCastOpcode(RESULT, \
-RESULT->getType()->isSigned(), DESTTY, DESTTY->isSigned());   \
-RESULT = CastInst::create(opcode, RESULT, DESTTY, "tmp", CurBB);  \
+LLVM_TARGET_INTRINSIC_CAST_RESULT(RESULT,RESISSIGNED,DESTTY,EXPISSIGNED); \
 return true;  \
   }   \
   case IX86_BUILTIN_PSLLDI128: {  \
@@ -410

Re: [llvm-commits] [llvm-gcc] Removal of signedness from gcc/config/i386/i386.h

2006-12-20 Thread Chris Lattner
>> Although this patch removes isSigned() calls and is correct, it is  
>> not
>> optimal. It is still using CastInst::getCastOpcode to figure out the
>> casting opcode for it. Perhaps someone with a little more  
>> knowledge of
>> the intrinsic functions could narrow these down to the appropriate  
>> cast
>> opcode.

This is fine.  When the whole patch lands, please ping evan.  Most of  
those casts are obviously bitcasts (vector -> vector).

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


Re: [llvm-commits] SETCC InstructionCombining.cpp [#1/n]

2006-12-20 Thread Chris Lattner

On Dec 17, 2006, at 3:35 PM, Reid Spencer wrote:

> Chris,
>
> Attached is the patch to InstructionCombining.cpp for SETCC conversion
> to ICmpInst. This passes all tests.
>
> All your previous feedback has been incorporated and confirmed. The  
> test
> just completed includes all those changes as well.
>
> I'm looking forward to finally committing the SETCC patch so we can
> finish it off and then start removing unnecessary casts and  
> unifying the
> integer types.

+// SimplifyCompare - For a CmpInst this function just orders the  
operands
+// so that theyare listed from right (least complex) to left (most  
complex).
+// This puts constants before unary operators before binary operators.
+//
+bool InstCombiner::SimplifyCompare(CmpInst &I) {

Please doxygenify the comment.

+  bool Changed = false;
+  if (getComplexity(I.getOperand(0)) < getComplexity(I.getOperand 
(1))) {
+I.swapOperands();
+Changed = true;
+  }
+  // Compare instructions are not associative so there's nothing  
else we can do.
+  return Changed;
+}

Why not:

   if (getComplexity(I.getOperand(0)) >= getComplexity(I.getOperand(1)))
 return false;
   I.swapOperands();
   return true;

?



  // isTrueWhenEqual - Return true if the specified setcondinst  
instruction is
  // true when both operands are equal...
  //
  static bool isTrueWhenEqual(Instruction &I) {
+  if (ICmpInst *ICI = dyn_cast(&I))
+return ICI->getPredicate() == ICmpInst::ICMP_EQ  ||
+   ICI->getPredicate() == ICmpInst::ICMP_UGE ||
+   ICI->getPredicate() == ICmpInst::ICMP_SGE ||
+   ICI->getPredicate() == ICmpInst::ICMP_ULE ||
+   ICI->getPredicate() == ICmpInst::ICMP_SLE;
return I.getOpcode() == Instruction::SetEQ ||
   I.getOpcode() == Instruction::SetGE ||
   I.getOpcode() == Instruction::SetLE;
  }

This should be split into two functions, one for ICmpInst and one for  
FCmpInst/SetCondInst.  Since your touching it, plz doxygenify also. :)



@@ -1580,21 +1607,31 @@ static Value *FoldOperationIntoSelectOpe
// Figure out if the constant is the left or the right argument.
bool ConstIsRHS = isa(I.getOperand(1));
Constant *ConstOperand = cast(I.getOperand(ConstIsRHS));

if (Constant *SOC = dyn_cast(SO)) {
-if (ConstIsRHS)
-  return ConstantExpr::get(I.getOpcode(), SOC, ConstOperand);
-return ConstantExpr::get(I.getOpcode(), ConstOperand, SOC);
+if (CmpInst *CI = dyn_cast(&I)) {
+  unsigned short pred = CI->getPredicate();
+  if (ConstIsRHS)
+return ConstantExpr::getCompare(pred, SOC, ConstOperand);
+  return ConstantExpr::getCompare(pred, ConstOperand, SOC);

This code doesn't appear to be called for compares.  Is it?  If so,  
the code is broken, you can't just swap the LHS/RHS of a compare like  
that without breaking things.


+/// isSignBitCheck - Given an exploded icmp instruction, return true  
if it
  /// really just returns true if the most significant (sign) bit is  
set.
+static bool isSignBitCheck(ICmpInst::Predicate pred, Value *LHS,
+   ConstantInt *RHS) {

There is no reason to pass LHS into this function (this is an  
absolute statement, not a bug in your patch) please remove LHS.


+case ICmpInst::ICMP_UGE:
+  // True if LHS u>= RHS and RHS == high-bit-mask (2^7, 2^15,  
2^31, etc)
+  return RHS->getZExtValue() == 1ULL <<
+RHS->getType()->getPrimitiveSizeInBits()-1;

Please add parens to make the precedence more explicit, even though  
it is right.


More tomorrow,

-Chris


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


[llvm-commits] CVS: llvm/lib/Analysis/ScalarEvolution.cpp

2006-12-20 Thread Reid Spencer


Changes in directory llvm/lib/Analysis:

ScalarEvolution.cpp updated: 1.74 -> 1.75
---
Log message:

Add some comments about things that can go away once signless types are in.


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

 ScalarEvolution.cpp |9 -
 1 files changed, 8 insertions(+), 1 deletion(-)


Index: llvm/lib/Analysis/ScalarEvolution.cpp
diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.74 
llvm/lib/Analysis/ScalarEvolution.cpp:1.75
--- llvm/lib/Analysis/ScalarEvolution.cpp:1.74  Tue Dec 19 16:30:33 2006
+++ llvm/lib/Analysis/ScalarEvolution.cpp   Thu Dec 21 00:43:46 2006
@@ -173,6 +173,8 @@
 
 SCEVHandle SCEVConstant::get(ConstantInt *V) {
   // Make sure that SCEVConstant instances are all unsigned.
+  // FIXME:Signless. This entire if statement can be removed when integer types
+  // are signless. There won't be a need to bitcast then.
   if (V->getType()->isSigned()) {
 const Type *NewTy = V->getType()->getUnsignedVersion();
 V = cast(
@@ -459,7 +461,10 @@
 C = Constant::getNullValue(Ty);
   else if (Ty->isFloatingPoint())
 C = ConstantFP::get(Ty, Val);
-  else if (Ty->isSigned())
+  /// FIXME:Signless. when integer types are signless, just change this to:
+  /// else
+  ///   C = ConstantInt::get(Ty, Val);
+  else if (Ty->isSigned())
 C = ConstantInt::get(Ty, Val);
   else {
 C = ConstantInt::get(Ty->getSignedVersion(), Val);
@@ -1574,6 +1579,8 @@
 
   // Now that we have it, if it's signed, convert it to an unsigned
   // range.
+  // FIXME:Signless. This entire if statement can go away when 
+  // integers are signless.  ConstantRange is already signless.
   if (CompRange.getLower()->getType()->isSigned()) {
 const Type *NewTy = RHSC->getValue()->getType();
 Constant *NewL = ConstantExpr::getBitCast(CompRange.getLower(), 



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


[llvm-commits] CVS: llvm-test/Makefile.rules

2006-12-20 Thread Reid Spencer


Changes in directory llvm-test:

Makefile.rules updated: 1.20 -> 1.21
---
Log message:

Restore definitions of LCC1 and LCC1PLUS to cause test programs to be
dependent upon the llvm-gcc compiler components they use.


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

 Makefile.rules |3 +++
 1 files changed, 3 insertions(+)


Index: llvm-test/Makefile.rules
diff -u llvm-test/Makefile.rules:1.20 llvm-test/Makefile.rules:1.21
--- llvm-test/Makefile.rules:1.20   Fri Dec  8 11:11:37 2006
+++ llvm-test/Makefile.rulesThu Dec 21 00:57:35 2006
@@ -774,6 +774,9 @@
 
 endif
 
+LCC1 := $(LLVMGCCDIR)/libexec/gcc/$(LLVMGCCARCH)/cc1
+LCC1XX := $(LLVMGCCDIR)/libexec/gcc/$(LLVMGCCARCH)/cc1plus
+LCOLLECT2 :=$(LLVMGCCDIR)/libexec/gcc/$(LLVMGCCARCH)/collect2 
 
 
 #-



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


Re: [llvm-commits] [llvm-gcc] Cast Fix

2006-12-20 Thread Reid Spencer
Chris, 

You asked for a case where I need to (recursively) determine the sign of
a some Value. I have a case in mind:
lib/Transforms/Utils/LowerSwitch.cpp.  When it decides to lower this to
a branch tree it is recursively calling switchConvert and passing the
switch value in. The signedness is needed in order to generate the
ICmpInst with either SLT or ULT for the branch tree. But that Value*
being tested originates from operand 0 of the switch instruction.
There's no way to determine if its signed or unsigned without starting
to look at it. As I noted in my example below, it could take several
steps of tracking through instructions before I come up with a
definitive answer. And there may be no way to determine it statically if
that search ends up at an argument, global variable, or constant.

Can we just make switch staetments always use SLT for the comparison and
have the issue go away? 

Reid.

On Mon, 2006-12-18 at 23:15 -0800, Chris Lattner wrote:
> >> You're basing all of the checks here on whether or not the LLVM types
> >> are signed.  I understand that this is the most expedient way to get
> >> stuff working in the short term, but this isn't going to work long
> >> term, as the ->isSigned() methods are not going to exist any more.
> >> You should eventually migrate these to using TREE_UNSIGNED and
> >> similar macros, checking properties from the GCC trees.
> >
> > Yes, I understand. I was solely working towards a) fixing the breakage
> > and b) retaining current functionality. There were a lot of changes to
> > make in a short time to get llvm-gcc compiling again. Many of these  
> > need
> > some deep analysis and rather than delay the patch, I took this route.
> 
> Yep, makes sense.
> 
> >>
> >> Further, the casts in i386.h that call getCastOpcode, should be
> >> updated to use the appropriate cast.  However, I'm not sure what they
> >> are, you can work with Evan to figure them out.
> >
> > I tried a few of them as specific casts and it broke many things which
> > is just an indication that I didn't fully analyze the set of types  
> > that
> > can be passed in. The places were getCastOpcode will remain in use are
> > those places where the type could be anything or close to anything  
> > (e.g.
> > function arguments and returns).  These also will be reviewed in more
> > detail as I continue to remove signlessness.
> 
> Ok.
> 
> > FYI: my strategy here is to work from the bottom up. With the last few
> > patches VMCore contains only one isSigned() call (in AsmWriter). I'm
> > currently working on a fix for that. Once VMCore is clean, I'll  
> > move on
> > to other libraries and on up the chain, removing getCastOpcode,
> > isSigned, isUnsigned, getSignedVersion, getUnsignedVersion, etc.
> 
> Nice.
> 
> > This will take a while, many of the remaining cases require some
> > significant modifications in order to figure out if the value is  
> > signed
> > or not.  Speaking of which, I was thinking of adding a method to
> > Instruction, isSignedOperand(unsigned) which recursively figures  
> > out if
> > the operand can be signed. Consider a bunch of arithmetic based on a
> > ZExt or SExt, something like:
> >
> > bool %func(sbyte %a) {
> >%b = zext sbyte %a to short
> >%c = sext sbyte %a to ushort
> >%d = add short %b, %b
> >%e = add ushort %c, %c
> >%f = bitcast short %d to ushort
> >%ret = call bool %doit(ushort %f, short %d)
> >ret bool %ret
> > }
> >
> > In such a function the declared types are meaningless. %b is  
> > unsigned. %
> > c is signed. When it comes time to check the parameters to %doit, I  
> > need
> > to know that. About the only way I can think of is to write a function
> > on Instruction that recursively calls itself following the use chain
> > until it finds something that is concretely signed or not. Even this
> > might not help. Suppose the zext and sext weren't in this function. I
> > can't statically determine the signedness of sbyte %a which might be
> > signed or not.
> 
> I don't think this is a good idea.  What specific clients would use  
> this?
> 
> -Chris

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


[llvm-commits] CVS: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp

2006-12-20 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/IPO:

SimplifyLibCalls.cpp updated: 1.78 -> 1.79
---
Log message:

Get rid of a useless if statement whose then and else blocks were identical.


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

 SimplifyLibCalls.cpp |5 +
 1 files changed, 1 insertion(+), 4 deletions(-)


Index: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
diff -u llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.78 
llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.79
--- llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.78   Tue Dec 19 17:16:47 2006
+++ llvm/lib/Transforms/IPO/SimplifyLibCalls.cppThu Dec 21 01:15:54 2006
@@ -920,10 +920,7 @@
 
 // strlen("xyz") -> 3 (for example)
 const Type *Ty = SLC.getTargetData()->getIntPtrType();
-if (Ty->isSigned())
-  ci->replaceAllUsesWith(ConstantInt::get(Ty, len));
-else
-  ci->replaceAllUsesWith(ConstantInt::get(Ty, len));
+ci->replaceAllUsesWith(ConstantInt::get(Ty, len));
  
 ci->eraseFromParent();
 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/Transforms/Instrumentation/ProfilingUtils.cpp

2006-12-20 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Instrumentation:

ProfilingUtils.cpp updated: 1.11 -> 1.12
---
Log message:

Remove isSigned calls via foreknowledge of main's argument types.


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

 ProfilingUtils.cpp |   11 ---
 1 files changed, 4 insertions(+), 7 deletions(-)


Index: llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp
diff -u llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp:1.11 
llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp:1.12
--- llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp:1.11 Mon Dec 18 
02:47:13 2006
+++ llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp  Thu Dec 21 
01:49:49 2006
@@ -62,8 +62,8 @@
   case 2:
 AI = MainFn->arg_begin(); ++AI;
 if (AI->getType() != ArgVTy) {
-  Instruction::CastOps opcode = CastInst::getCastOpcode(AI,
-  AI->getType()->isSigned(), ArgVTy, ArgVTy->isSigned());
+  Instruction::CastOps opcode = CastInst::getCastOpcode(AI, false, ArgVTy, 
+false);
   InitCall->setOperand(2, 
   CastInst::create(opcode, AI, ArgVTy, "argv.cast", InitCall));
 } else {
@@ -78,14 +78,11 @@
 if (AI->getType() != Type::IntTy) {
   Instruction::CastOps opcode;
   if (!AI->use_empty()) {
-opcode = CastInst::getCastOpcode(InitCall, 
-InitCall->getType()->isSigned(), AI->getType(), 
-AI->getType()->isSigned());
+opcode = CastInst::getCastOpcode(InitCall, true, AI->getType(), true);
 AI->replaceAllUsesWith(
   CastInst::create(opcode, InitCall, AI->getType(), "", InsertPos));
   }
-  opcode = CastInst::getCastOpcode(AI, AI->getType()->isSigned(),
-  Type::IntTy, true);
+  opcode = CastInst::getCastOpcode(AI, true, Type::IntTy, true);
   InitCall->setOperand(1, 
   CastInst::create(opcode, AI, Type::IntTy, "argc.cast", InitCall));
 } else {



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