[llvm-commits] CVS: llvm/test/Regression/ExecutionEngine/2002-12-16-ArgTest.ll 2003-01-04-ArgumentBug.ll 2003-01-09-SARTest.ll 2003-01-15-AlignmentTest.ll 2003-08-21-EnvironmentTest.ll 2003-10-18-PHIN
Changes in directory llvm/test/Regression/ExecutionEngine: 2002-12-16-ArgTest.ll updated: 1.4 -> 1.5 2003-01-04-ArgumentBug.ll updated: 1.3 -> 1.4 2003-01-09-SARTest.ll updated: 1.2 -> 1.3 2003-01-15-AlignmentTest.ll updated: 1.2 -> 1.3 2003-08-21-EnvironmentTest.ll updated: 1.4 -> 1.5 2003-10-18-PHINode-ConstantExpr-CondCode-Failure.ll updated: 1.3 -> 1.4 test-arith.ll updated: 1.11 -> 1.12 test-call.ll updated: 1.7 -> 1.8 test-cast.ll updated: 1.10 -> 1.11 test-fp.ll updated: 1.5 -> 1.6 test-phi.ll updated: 1.5 -> 1.6 test-shift.ll updated: 1.6 -> 1.7 --- Log message: These tests need llvm-upgrade. This fixes last night's nightly test fallout. --- Diffs of the changes: (+12 -12) 2002-12-16-ArgTest.ll |2 +- 2003-01-04-ArgumentBug.ll |2 +- 2003-01-09-SARTest.ll |2 +- 2003-01-15-AlignmentTest.ll |2 +- 2003-08-21-EnvironmentTest.ll |2 +- 2003-10-18-PHINode-ConstantExpr-CondCode-Failure.ll |2 +- test-arith.ll |2 +- test-call.ll|2 +- test-cast.ll|2 +- test-fp.ll |2 +- test-phi.ll |2 +- test-shift.ll |2 +- 12 files changed, 12 insertions(+), 12 deletions(-) Index: llvm/test/Regression/ExecutionEngine/2002-12-16-ArgTest.ll diff -u llvm/test/Regression/ExecutionEngine/2002-12-16-ArgTest.ll:1.4 llvm/test/Regression/ExecutionEngine/2002-12-16-ArgTest.ll:1.5 --- llvm/test/Regression/ExecutionEngine/2002-12-16-ArgTest.ll:1.4 Sat Nov 6 17:32:43 2004 +++ llvm/test/Regression/ExecutionEngine/2002-12-16-ArgTest.ll Sun Dec 3 10:17:19 2006 @@ -1,4 +1,4 @@ -; RUN: llvm-as -f %s -o %t.bc +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc ; RUN: lli %t.bc > /dev/null %.LC0 = internal global [10 x sbyte] c"argc: %d\0A\00" Index: llvm/test/Regression/ExecutionEngine/2003-01-04-ArgumentBug.ll diff -u llvm/test/Regression/ExecutionEngine/2003-01-04-ArgumentBug.ll:1.3 llvm/test/Regression/ExecutionEngine/2003-01-04-ArgumentBug.ll:1.4 --- llvm/test/Regression/ExecutionEngine/2003-01-04-ArgumentBug.ll:1.3 Sat Nov 6 17:32:43 2004 +++ llvm/test/Regression/ExecutionEngine/2003-01-04-ArgumentBug.ll Sun Dec 3 10:17:19 2006 @@ -1,4 +1,4 @@ -; RUN: llvm-as -f %s -o %t.bc +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc ; RUN: lli %t.bc > /dev/null Index: llvm/test/Regression/ExecutionEngine/2003-01-09-SARTest.ll diff -u llvm/test/Regression/ExecutionEngine/2003-01-09-SARTest.ll:1.2 llvm/test/Regression/ExecutionEngine/2003-01-09-SARTest.ll:1.3 --- llvm/test/Regression/ExecutionEngine/2003-01-09-SARTest.ll:1.2 Sat Nov 6 17:32:43 2004 +++ llvm/test/Regression/ExecutionEngine/2003-01-09-SARTest.ll Sun Dec 3 10:17:19 2006 @@ -1,4 +1,4 @@ -; RUN: llvm-as -f %s -o %t.bc +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc ; RUN: lli %t.bc > /dev/null ; We were accidentally inverting the signedness of right shifts. Whoops. Index: llvm/test/Regression/ExecutionEngine/2003-01-15-AlignmentTest.ll diff -u llvm/test/Regression/ExecutionEngine/2003-01-15-AlignmentTest.ll:1.2 llvm/test/Regression/ExecutionEngine/2003-01-15-AlignmentTest.ll:1.3 --- llvm/test/Regression/ExecutionEngine/2003-01-15-AlignmentTest.ll:1.2 Sat Nov 6 17:32:43 2004 +++ llvm/test/Regression/ExecutionEngine/2003-01-15-AlignmentTest.llSun Dec 3 10:17:19 2006 @@ -1,4 +1,4 @@ -; RUN: llvm-as -f %s -o %t.bc +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc ; RUN: lli %t.bc > /dev/null Index: llvm/test/Regression/ExecutionEngine/2003-08-21-EnvironmentTest.ll diff -u llvm/test/Regression/ExecutionEngine/2003-08-21-EnvironmentTest.ll:1.4 llvm/test/Regression/ExecutionEngine/2003-08-21-EnvironmentTest.ll:1.5 --- llvm/test/Regression/ExecutionEngine/2003-08-21-EnvironmentTest.ll:1.4 Sat Nov 6 17:32:43 2004 +++ llvm/test/Regression/ExecutionEngine/2003-08-21-EnvironmentTest.ll Sun Dec 3 10:17:19 2006 @@ -1,4 +1,4 @@ -; RUN: llvm-as -f %s -o %t.bc +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc ; RUN: lli %t.bc > /dev/null ; Index: llvm/test/Regression/ExecutionEngine/2003-10-18-PHINode-ConstantExpr-CondCode-Failure.ll diff -u llvm/test/Regression/ExecutionEngine/2003-10-18-PHINode-ConstantExpr-CondCode-Failure.ll:1.3 llvm/test/Regression/ExecutionEngine/2003-10-18-PHINode-ConstantExpr-CondCode-Failure.ll:1.4 --- llvm/test/Regression/ExecutionEngine/2003-10-18-PHINode-ConstantExpr-CondCode-Failure.ll:1.3 Sat Nov 6 17:32:43 2004 +++ llvm/test/Regression/ExecutionEngine/2003-10-18-PHINode-ConstantExpr-CondCode-Failure.ll Sun Dec 3 10:17:19 2006 @@ -1,4 +1,4 @@ -; RUN: llvm-as -f %s -o %t.bc +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc ; RUN: lli %t.bc > /dev/null %A =
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.282 -> 1.283 --- Log message: Remove useless #include. --- Diffs of the changes: (+0 -1) llvmAsmParser.y |1 - 1 files changed, 1 deletion(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.282 llvm/lib/AsmParser/llvmAsmParser.y:1.283 --- llvm/lib/AsmParser/llvmAsmParser.y:1.282Sun Dec 3 00:58:07 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Dec 3 10:19:43 2006 @@ -18,7 +18,6 @@ #include "llvm/Instructions.h" #include "llvm/Module.h" #include "llvm/SymbolTable.h" -#include "llvm/Assembly/AutoUpgrade.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/MathExtras.h" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/VMCore/AutoUpgrade.cpp
Changes in directory llvm/lib/VMCore: AutoUpgrade.cpp (r1.22) removed --- Log message: Remove dead code. --- Diffs of the changes: (+0 -0) 0 files changed ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Assembly/AutoUpgrade.h
Changes in directory llvm/include/llvm/Assembly: AutoUpgrade.h (r1.7) removed --- Log message: Remove dead code. --- Diffs of the changes: (+0 -0) 0 files changed ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/test/Regression/CFrontend/extern-weak.c
Changes in directory llvm/test/Regression/CFrontend: extern-weak.c updated: 1.2 -> 1.3 --- Log message: Use weak_import on linux, weak everywhere else. Makes test pass on Linux. Checking for __APPLE_CC__ is useless as this just checks to see if the compiler is llvm-gcc, which we know it is. --- Diffs of the changes: (+1 -1) extern-weak.c |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/test/Regression/CFrontend/extern-weak.c diff -u llvm/test/Regression/CFrontend/extern-weak.c:1.2 llvm/test/Regression/CFrontend/extern-weak.c:1.3 --- llvm/test/Regression/CFrontend/extern-weak.c:1.2Fri Dec 1 12:04:08 2006 +++ llvm/test/Regression/CFrontend/extern-weak.cSun Dec 3 10:40:08 2006 @@ -1,7 +1,7 @@ // RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | grep extern_weak && // RUN: %llvmgcc -O3 -S -o - -emit-llvm | llvm-as | llc -#ifdef __APPLE_CC__ +#ifndef __linux__ void foo() __attribute__((weak_import)); #else void foo() __attribute__((weak)); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/docs/LangRef.html
Changes in directory llvm/docs: LangRef.html updated: 1.174 -> 1.175 --- Log message: Update for signless GEP semantics. --- Diffs of the changes: (+8 -7) LangRef.html | 15 --- 1 files changed, 8 insertions(+), 7 deletions(-) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.174 llvm/docs/LangRef.html:1.175 --- llvm/docs/LangRef.html:1.174Mon Nov 27 15:53:28 2006 +++ llvm/docs/LangRef.html Sun Dec 3 10:53:48 2006 @@ -2491,9 +2491,9 @@ provided depend on the type of the first pointer argument. The 'getelementptr' instruction is used to index down through the type levels of a structure or to a specific index in an array. When indexing into a -structure, only uint -integer constants are allowed. When indexing into an array or pointer, -int and long and ulong indexes are allowed. +structure, only uint integer constants are allowed. When indexing +into an array or pointer, integers of any size are allowed, and will be sign +extended to 64-bit values. For example, let's consider a C code fragment and how it gets compiled to LLVM: @@ -2534,9 +2534,10 @@ The index types specified for the 'getelementptr' instruction depend on the pointer type that is being indexed into. Pointer -and array types require int, -ulong, or long values, and structure -types require uint constants. +and array types can use any +integer type but the value will always be sign extended +to 64-bits. Structure types, require uint +constants. In the example above, the first index is indexing into the '%ST*' type, which is a pointer, yielding a '%ST' = '{ int, double, %RT @@ -4426,7 +4427,7 @@ mailto:[EMAIL PROTECTED]">Chris Lattner http://llvm.org";>The LLVM Compiler Infrastructure - Last modified: $Date: 2006/11/27 21:53:28 $ + Last modified: $Date: 2006/12/03 16:53:48 $ ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp
Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.209 -> 1.210 --- Log message: Support ICmp/FCmp constant expression reading and writing. --- Diffs of the changes: (+12 -0) Reader.cpp | 12 1 files changed, 12 insertions(+) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.209 llvm/lib/Bytecode/Reader/Reader.cpp:1.210 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.209 Sun Dec 3 00:28:54 2006 +++ llvm/lib/Bytecode/Reader/Reader.cpp Sun Dec 3 11:17:02 2006 @@ -701,6 +701,8 @@ } case Instruction::ICmp: case Instruction::FCmp: + if (Oprnds.size() != 3) +error("Cmp instructions requires 3 operands"); // These instructions encode the comparison predicate as the 3rd operand. Result = CmpInst::create(Instruction::OtherOps(Opcode), static_cast(Oprnds[2]), @@ -1351,6 +1353,16 @@ ConstantExpr::getShuffleVector(ArgVec[0], ArgVec[1], ArgVec[2]); if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); return Result; +} else if (Opcode == Instruction::ICmp) { + if (ArgVec.size() != 2) +error("Invalid ICmp constant expr arguments"); + unsigned short pred = read_vbr_uint(); + return ConstantExpr::getICmp(pred, ArgVec[0], ArgVec[1]); +} else if (Opcode == Instruction::FCmp) { + if (ArgVec.size() != 2) +error("Invalid FCmp constant expr arguments"); + unsigned short pred = read_vbr_uint(); + return ConstantExpr::getFCmp(pred, ArgVec[0], ArgVec[1]); } else {// All other 2-operand expressions Constant* Result = ConstantExpr::get(Opcode, ArgVec[0], ArgVec[1]); if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp
Changes in directory llvm/lib/Bytecode/Writer: Writer.cpp updated: 1.131 -> 1.132 --- Log message: Support ICmp/FCmp constant expression reading and writing. --- Diffs of the changes: (+7 -0) Writer.cpp |7 +++ 1 files changed, 7 insertions(+) Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.131 llvm/lib/Bytecode/Writer/Writer.cpp:1.132 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.131 Sun Dec 3 00:28:54 2006 +++ llvm/lib/Bytecode/Writer/Writer.cpp Sun Dec 3 11:17:02 2006 @@ -791,6 +791,13 @@ } } + // In the weird case of the ICmp or FCmp instructions, we need to also put + // out the instruction's predicate value. We do that here, after the + // instruction's type and operands have been written so we can reuse the + // code above. + if (const CmpInst* CI = dyn_cast(&I)) +output_vbr((unsigned)CI->getPredicate()); + // If we weren't handled before here, we either have a large number of // operands or a large operand index that we are referring to. outputInstructionFormat0(&I, Opcode, Table, Type); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/test/Regression/CFrontend/extern-weak.c
> > Use weak_import on linux, weak everywhere else. Makes test pass on > Linux. > Checking for __APPLE_CC__ is useless as this just checks to see if the > compiler is llvm-gcc, which we know it is. This description is wrong, and doesn't match the change you made to the testcase. I believe we want to use weak_import only on __APPLE_CC__ targets, as the test case originally did. -Chris > --- > Diffs of the changes: (+1 -1) > > extern-weak.c |2 +- > 1 files changed, 1 insertion(+), 1 deletion(-) > > > Index: llvm/test/Regression/CFrontend/extern-weak.c > diff -u llvm/test/Regression/CFrontend/extern-weak.c:1.2 llvm/test/ > Regression/CFrontend/extern-weak.c:1.3 > --- llvm/test/Regression/CFrontend/extern-weak.c:1.2 Fri Dec 1 > 12:04:08 2006 > +++ llvm/test/Regression/CFrontend/extern-weak.c Sun Dec 3 > 10:40:08 2006 > @@ -1,7 +1,7 @@ > // RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | grep extern_weak && > // RUN: %llvmgcc -O3 -S -o - -emit-llvm | llvm-as | llc > > -#ifdef __APPLE_CC__ > +#ifndef __linux__ > void foo() __attribute__((weak_import)); > #else > void foo() __attribute__((weak)); > > > > ___ > 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
[llvm-commits] CVS: llvm/Makefile.rules
Changes in directory llvm: Makefile.rules updated: 1.412 -> 1.413 --- Log message: Handle upgrade of llvm-gcc3 assembly files. --- Diffs of the changes: (+24 -0) Makefile.rules | 24 1 files changed, 24 insertions(+) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.412 llvm/Makefile.rules:1.413 --- llvm/Makefile.rules:1.412 Thu Nov 16 21:32:33 2006 +++ llvm/Makefile.rules Sun Dec 3 15:01:45 2006 @@ -320,6 +320,18 @@ ifndef LBUGPOINT LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT) endif +ifndef LUPGRADE +LUPGRADE := $(LLVMToolDir)/llvm-upgrade$(EXEEXT) +endif +ifeq ($(LLVMGCC_MAJVERS),3) +UPGRADE_MSG = $(Echo) "Upgrading $(1) assembly to latest." +UPGRADE_LL = $(Verb)$(LUPGRADE) $(1) -o $(1).up.tmp -f ; $(MV) $(1).up.tmp $(1) +else +UPGRADE_MSG = +UPGRADE_LL = +endif + +LLVMGCC_MAJVERS := 4 LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC) LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX) @@ -1028,6 +1040,8 @@ $< -o $@ -S -emit-llvm ; \ then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \ else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi + $(call UPGRADE_MSG,$@) + $(call UPGRADE_LL,$@) $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)" @@ -1035,6 +1049,8 @@ $< -o $@ -S -emit-llvm ; \ then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \ else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi + $(call UPGRADE_MSG,$@) + $(call UPGRADE_LL,$@) $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)" @@ -1042,6 +1058,8 @@ $< -o $@ -S -emit-llvm ; \ then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \ else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi + $(call UPGRADE_MSG,$@) + $(call UPGRADE_LL,$@) # Provide alternate rule sets if dependencies are disabled else @@ -1061,14 +1079,20 @@ $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)" $(BCCompile.CXX) $< -o $@ -S -emit-llvm + $(call UPGRADE_MSG,$@) + $(call UPGRADE_LL,$@) $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)" $(BCCompile.CXX) $< -o $@ -S -emit-llvm + $(call UPGRADE_MSG,$@) + $(call UPGRADE_LL,$@) $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)" $(BCCompile.C) $< -o $@ -S -emit-llvm + $(call UPGRADE_MSG,@) + $(call UPGRADE_LL,@) endif ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/Makefile.rules
Changes in directory llvm: Makefile.rules updated: 1.413 -> 1.414 --- Log message: Remove line not meant to be committed. --- Diffs of the changes: (+0 -2) Makefile.rules |2 -- 1 files changed, 2 deletions(-) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.413 llvm/Makefile.rules:1.414 --- llvm/Makefile.rules:1.413 Sun Dec 3 15:01:45 2006 +++ llvm/Makefile.rules Sun Dec 3 15:17:12 2006 @@ -331,8 +331,6 @@ UPGRADE_LL = endif -LLVMGCC_MAJVERS := 4 - LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC) LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX) ___ 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 Makefile.tests
Changes in directory llvm-test: Makefile.rules updated: 1.18 -> 1.19 Makefile.tests updated: 1.12 -> 1.13 --- Log message: Handle upgrade of llvm-gcc3 output by running llvm-upgrade on it. --- Diffs of the changes: (+11 -0) Makefile.rules |7 +++ Makefile.tests |4 2 files changed, 11 insertions(+) Index: llvm-test/Makefile.rules diff -u llvm-test/Makefile.rules:1.18 llvm-test/Makefile.rules:1.19 --- llvm-test/Makefile.rules:1.18 Tue Nov 7 17:17:30 2006 +++ llvm-test/Makefile.rulesSun Dec 3 15:15:49 2006 @@ -281,6 +281,13 @@ LPROF = $(LLVMTOOLCURRENT)/llvm-prof$(EXEEXT) LBUGPOINT = $(LLVMTOOLCURRENT)/bugpoint$(EXEEXT) LLVMC = $(LLVMTOOLCURRENT)/llvmc$(EXEEXT) +LUPGRADE = $(LLVMTOOLCURRENT)/llvm-upgrade$(EXEEXT) +ifeq ($(LLVMGCC_MAJVERS),3) +UPGRADE_LL= $(LUPGRADE) $(1) -o $(1).up.tmp -f ; $(MV) $(1).up.tmp $(1) +else +UPGRADE_LL= +endif + ### Index: llvm-test/Makefile.tests diff -u llvm-test/Makefile.tests:1.12 llvm-test/Makefile.tests:1.13 --- llvm-test/Makefile.tests:1.12 Mon Oct 9 13:24:03 2006 +++ llvm-test/Makefile.testsSun Dec 3 15:15:49 2006 @@ -51,18 +51,22 @@ # Compile from X.c to Output/X.ll Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES) -$(LLVMGCC) $(CPPFLAGS) $(LCCFLAGS) $(TARGET_FLAGS) -O0 -S $< -o $@ -emit-llvm + -$(call UPGRADE_LL,$@) # Compile from X.cpp to Output/X.ll Output/%.ll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES) -$(LLVMGXX) $(CPPFLAGS) $(LCXXFLAGS) $(TARGET_FLAGS) -O0 -S $< -o $@ -emit-llvm + -$(call UPGRADE_LL,$@) # Compile from X.cc to Output/X.ll Output/%.ll: %.cc $(LCC1XX) Output/.dir $(INCLUDES) -$(LLVMGXX) $(CPPFLAGS) $(LCXXFLAGS) $(TARGET_FLAGS) -O0 -S $< -o $@ -emit-llvm + -$(call UPGRADE_LL,$@) # Compile from X.C to Output/X.ll Output/%.ll: %.C $(LCC1XX) Output/.dir $(INCLUDES) -$(LLVMGXX) $(CPPFLAGS) $(LCXXFLAGS) $(TARGET_FLAGS) -O0 -S $< -o $@ -emit-llvm + -$(call UPGRADE_LL,$@) # LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come # from GCC output, so use GCCAS. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Analysis/ConstantRange.cpp
Changes in directory llvm/lib/Analysis: ConstantRange.cpp updated: 1.18 -> 1.19 --- Log message: Change inferred casts to explicit casts. --- Diffs of the changes: (+5 -9) ConstantRange.cpp | 14 +- 1 files changed, 5 insertions(+), 9 deletions(-) Index: llvm/lib/Analysis/ConstantRange.cpp diff -u llvm/lib/Analysis/ConstantRange.cpp:1.18 llvm/lib/Analysis/ConstantRange.cpp:1.19 --- llvm/lib/Analysis/ConstantRange.cpp:1.18Tue Nov 28 19:14:00 2006 +++ llvm/lib/Analysis/ConstantRange.cpp Sun Dec 3 20:46:44 2006 @@ -293,14 +293,9 @@ Constant *Lower = getLower(); Constant *Upper = getUpper(); - if (Lower->getType()->isInteger() && !Lower->getType()->isUnsigned()) { -// Ensure we are doing a ZERO extension even if the input range is signed. -Lower = ConstantExpr::getCast(Lower, Ty->getUnsignedVersion()); -Upper = ConstantExpr::getCast(Upper, Ty->getUnsignedVersion()); - } - return ConstantRange(ConstantExpr::getCast(Lower, Ty), - ConstantExpr::getCast(Upper, Ty)); + return ConstantRange(ConstantExpr::getCast(Instruction::ZExt, Lower, Ty), + ConstantExpr::getCast(Instruction::ZExt, Upper, Ty)); } /// truncate - Return a new range in the specified integer type, which must be @@ -314,8 +309,9 @@ if (isFullSet() || getSetSize() >= Size) return ConstantRange(getType()); - return ConstantRange(ConstantExpr::getCast(getLower(), Ty), - ConstantExpr::getCast(getUpper(), Ty)); + return ConstantRange( + ConstantExpr::getCast(Instruction::Trunc, getLower(), Ty), + ConstantExpr::getCast(Instruction::Trunc, getUpper(), Ty)); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/InstrTypes.h Constants.h
Changes in directory llvm/include/llvm: InstrTypes.h updated: 1.49 -> 1.50 Constants.h updated: 1.97 -> 1.98 --- Log message: Take a baby step towards getting rid of inferred casts. Provide methods on CastInst and ConstantExpr that allow the signedness to be explicitly passed in and reliance on signedness removed from getCastOpcode. These are temporary measures useful during the conversion of inferred casts. --- Diffs of the changes: (+32 -4) Constants.h |9 - InstrTypes.h | 27 --- 2 files changed, 32 insertions(+), 4 deletions(-) Index: llvm/include/llvm/InstrTypes.h diff -u llvm/include/llvm/InstrTypes.h:1.49 llvm/include/llvm/InstrTypes.h:1.50 --- llvm/include/llvm/InstrTypes.h:1.49 Sun Nov 26 19:05:09 2006 +++ llvm/include/llvm/InstrTypes.h Sun Dec 3 20:43:42 2006 @@ -303,7 +303,9 @@ /// rules. static Instruction::CastOps getCastOpcode( const Value *Val, ///< The value to cast -const Type *Ty///< The Type to which the value should be casted +bool SrcIsSigned, ///< Whether to treat the source as signed +const Type *Ty, ///< The Type to which the value should be casted +bool DstIsSigned ///< Whether to treate the dest. as signed ); /// Joins the create method (with insert-before-instruction semantics) above @@ -316,12 +318,21 @@ /// @brief Inline helper method to join create with getCastOpcode. inline static CastInst *createInferredCast( Value *S, ///< The value to be casted (operand 0) +bool SrcIsSigned, ///< Whether to treat the source as signed const Type *Ty, ///< Type to which operand should be casted +bool DstIsSigned, ///< Whether to treate the dest. as signed const std::string &Name = "", ///< Name for the instruction Instruction *InsertBefore = 0 ///< Place to insert the CastInst ) { -return create(getCastOpcode(S, Ty), S, Ty, Name, InsertBefore); +return create(getCastOpcode(S, SrcIsSigned, Ty, DstIsSigned), + S, Ty, Name, InsertBefore); } + static CastInst *createInferredCast( +Value *S, ///< The value to be casted (operand 0) +const Type *Ty, ///< Type to which operand should be casted +const std::string &Name = "", ///< Name for the instruction +Instruction *InsertBefore = 0 ///< Place to insert the CastInst + ); /// Joins the get method (with insert-at-end-of-block semantics) method /// above with the getCastOpcode method. getOpcode(S,Ty) is called first to @@ -334,13 +345,23 @@ /// @brief Inline helper method to join create with getCastOpcode. inline static CastInst *createInferredCast( Value *S, ///< The value to be casted (operand 0) +bool SrcIsSigned, ///< Whether to treat the source as signed const Type *Ty, ///< Type to which operand should be casted +bool DstIsSigned, ///< Whether to treate the dest. as signed const std::string &Name, ///< Name for the instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ) { -return create(getCastOpcode(S, Ty), S, Ty, Name, InsertAtEnd); +return create(getCastOpcode(S, SrcIsSigned, Ty, DstIsSigned), + S, Ty, Name, InsertAtEnd); } + static CastInst *createInferredCast( +Value *S, ///< The value to be casted (operand 0) +const Type *Ty, ///< Type to which operand should be casted +const std::string &Name, ///< Name for the instruction +BasicBlock *InsertAtEnd ///< The block to insert the instruction into + ); + /// There are several places where we need to know if a cast instruction /// only deals with integer source and destination types. To simplify that /// logic, this method is provided. Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.97 llvm/include/llvm/Constants.h:1.98 --- llvm/include/llvm/Constants.h:1.97 Sat Dec 2 23:48:19 2006 +++ llvm/include/llvm/Constants.h Sun Dec 3 20:43:42 2006 @@ -541,8 +541,15 @@ const Type *Ty ///< The type to which the constant is converted ); + // This method uses the CastInst::getCastOpcode method to infer the + // cast opcode to use. // @brief Get a ConstantExpr Conversion operator that casts C to Ty - static Constant *getCast(Constant *C, const Type *Ty); + static Constant *getInferredCast(Constant *C, bool SrcIsSigned, + const Type *Ty, bool DestIsSigned); + + static Constant *getCast(Constant *C, const Type *Ty) { +return getInferredCast(C, C->getType()->isSigned(), Ty, Ty->isSigned()); + } /// @brief Return true if this is a convert constant expression bool isCast() const; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs
[llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp
Changes in directory llvm/lib/VMCore: ConstantFolding.cpp updated: 1.105 -> 1.106 --- Log message: Change inferred casts to explicit casts. --- Diffs of the changes: (+23 -12) ConstantFolding.cpp | 35 +++ 1 files changed, 23 insertions(+), 12 deletions(-) Index: llvm/lib/VMCore/ConstantFolding.cpp diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.105 llvm/lib/VMCore/ConstantFolding.cpp:1.106 --- llvm/lib/VMCore/ConstantFolding.cpp:1.105 Fri Dec 1 13:50:54 2006 +++ llvm/lib/VMCore/ConstantFolding.cpp Sun Dec 3 20:45:43 2006 @@ -777,7 +777,8 @@ uint64_t V = DoubleToBits(cast(CP->getOperand(i))->getValue()); Constant *C = ConstantInt::get(Type::ULongTy, V); -Result.push_back(ConstantExpr::getCast(C, DstEltTy)); +Result.push_back( +ConstantExpr::getInferredCast(C, false, DstEltTy, false)); } return ConstantPacked::get(Result); } @@ -786,7 +787,8 @@ for (unsigned i = 0; i != SrcNumElts; ++i) { uint32_t V = FloatToBits(cast(CP->getOperand(i))->getValue()); Constant *C = ConstantInt::get(Type::UIntTy, V); - Result.push_back(ConstantExpr::getCast(C, DstEltTy)); + Result.push_back( +ConstantExpr::getInferredCast(C, false, DstEltTy, false)); } return ConstantPacked::get(Result); } @@ -839,8 +841,7 @@ // do to try to simplify it. if (const ConstantExpr *CE = dyn_cast(V)) { if (CE->isCast()) { - // Try hard to fold cast of cast because they are almost always - // eliminable. + // Try hard to fold cast of cast because they are often eliminable. if (unsigned newOpc = foldConstantCastPair(opc, CE, DestTy)) return ConstantExpr::getCast(newOpc, CE->getOperand(0), DestTy); } else if (CE->getOpcode() == Instruction::GetElementPtr) { @@ -853,6 +854,7 @@ break; } if (isAllNull) +// This is casting one pointer type to another, always BitCast return ConstantExpr::getCast(CE->getOperand(0), DestTy); } } @@ -1632,9 +1634,13 @@ // gep null, C is equal to C*sizeof(nullty). If nullty is a known llvm // type, we can statically fold this. Constant *R = ConstantInt::get(Type::UIntTy, ElSize); -R = ConstantExpr::getCast(R, Idx0->getType()); -R = ConstantExpr::getMul(R, Idx0); -return ConstantExpr::getCast(R, C->getType()); +// We know R is unsigned, Idx0 is signed because it must be an index +// through a sequential type (gep pointer operand) which is always +// signed. +R = ConstantExpr::getInferredCast(R, false, Idx0->getType(), true); +R = ConstantExpr::getMul(R, Idx0); // signed multiply +// R is a signed integer, C is the GEP pointer so -> IntToPtr +return ConstantExpr::getCast(Instruction::IntToPtr, R, C->getType()); } } } @@ -1662,11 +1668,16 @@ // Otherwise it must be an array. if (!Idx0->isNullValue()) { const Type *IdxTy = Combined->getType(); - if (IdxTy != Idx0->getType()) IdxTy = Type::LongTy; - Combined = -ConstantExpr::get(Instruction::Add, - ConstantExpr::getCast(Idx0, IdxTy), - ConstantExpr::getCast(Combined, IdxTy)); + if (IdxTy != Idx0->getType()) { +Constant *C1 = ConstantExpr::getInferredCast( +Idx0, true, Type::LongTy, true); +Constant *C2 = ConstantExpr::getInferredCast( +Combined, true, Type::LongTy, true); +Combined = ConstantExpr::get(Instruction::Add, C1, C2); + } else { +Combined = + ConstantExpr::get(Instruction::Add, Idx0, Combined); + } } NewIndices.push_back(Combined); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/VMCore/Instructions.cpp Constants.cpp
Changes in directory llvm/lib/VMCore: Instructions.cpp updated: 1.49 -> 1.50 Constants.cpp updated: 1.174 -> 1.175 --- Log message: Take a baby step towards getting rid of inferred casts. Provide methods on CastInst and ConstantExpr that allow the signedness to be explicitly passed in and reliance on signedness removed from getCastOpcode. These are temporary measures useful during the conversion of inferred casts. --- Diffs of the changes: (+26 -10) Constants.cpp| 13 +++-- Instructions.cpp | 23 +++ 2 files changed, 26 insertions(+), 10 deletions(-) Index: llvm/lib/VMCore/Instructions.cpp diff -u llvm/lib/VMCore/Instructions.cpp:1.49 llvm/lib/VMCore/Instructions.cpp:1.50 --- llvm/lib/VMCore/Instructions.cpp:1.49 Fri Dec 1 20:22:01 2006 +++ llvm/lib/VMCore/Instructions.cppSun Dec 3 20:43:42 2006 @@ -1507,7 +1507,8 @@ // should not assert in checkCast. In other words, this produces a "correct" // casting opcode for the arguments passed to it. Instruction::CastOps -CastInst::getCastOpcode(const Value *Src, const Type *DestTy) { +CastInst::getCastOpcode( + const Value *Src, bool SrcIsSigned, const Type *DestTy, bool DestIsSigned) { // Get the bit sizes, we'll need these const Type *SrcTy = Src->getType(); unsigned SrcBits = SrcTy->getPrimitiveSizeInBits(); // 0 for ptr/packed @@ -1519,7 +1520,7 @@ if (DestBits < SrcBits) return Trunc; // int -> smaller int else if (DestBits > SrcBits) {// its an extension -if (SrcTy->isSigned()) +if (SrcIsSigned) return SExt; // signed -> SEXT else return ZExt; // unsigned -> ZEXT @@ -1527,7 +1528,7 @@ return BitCast; // Same size, No-op cast } } else if (SrcTy->isFloatingPoint()) { // Casting from floating pt - if (DestTy->isSigned()) + if (DestIsSigned) return FPToSI; // FP -> sint else return FPToUI; // FP -> uint @@ -1542,7 +1543,7 @@ } } else if (DestTy->isFloatingPoint()) { // Casting to floating pt if (SrcTy->isIntegral()) { // Casting from integral - if (SrcTy->isSigned()) + if (SrcIsSigned) return SIToFP; // sint -> FP else return UIToFP; // uint -> FP @@ -1649,6 +1650,20 @@ } } +CastInst *CastInst::createInferredCast( + Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore) +{ + return createInferredCast(S, S->getType()->isSigned(), Ty, Ty->isSigned(), + Name, InsertBefore); +} + +CastInst *CastInst::createInferredCast( + Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) +{ + return createInferredCast(S, S->getType()->isSigned(), Ty, Ty->isSigned(), + Name, InsertAtEnd); +} + TruncInst::TruncInst( Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore ) : CastInst(Ty, Trunc, S, Name, InsertBefore) { Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.174 llvm/lib/VMCore/Constants.cpp:1.175 --- llvm/lib/VMCore/Constants.cpp:1.174 Sat Dec 2 23:48:19 2006 +++ llvm/lib/VMCore/Constants.cpp Sun Dec 3 20:43:42 2006 @@ -1486,9 +1486,11 @@ return ExprConstants->getOrCreate(Ty, Key); } -Constant *ConstantExpr::getCast( Constant *C, const Type *Ty ) { +Constant *ConstantExpr::getInferredCast(Constant *C, bool SrcIsSigned, +const Type *Ty, bool DestIsSigned) { // Note: we can't inline this because it requires the Instructions.h header - return getCast(CastInst::getCastOpcode(C, Ty), C, Ty); + return getCast( +CastInst::getCastOpcode(C, SrcIsSigned, Ty, DestIsSigned), C, Ty); } Constant *ConstantExpr::getCast(unsigned oc, Constant *C, const Type *Ty) { @@ -1612,10 +1614,9 @@ Constant *ConstantExpr::getSizeOf(const Type *Ty) { // sizeof is implemented as: (ulong) gep (Ty*)null, 1 - return getCast( -getGetElementPtr(getNullValue(PointerType::get(Ty)), - std::vector(1, ConstantInt::get(Type::UIntTy, 1))), -Type::ULongTy); + return getCast(Instruction::PtrToInt, getGetElementPtr(getNullValue( +PointerType::get(Ty)), std::vector(1, +ConstantInt::get(Type::UIntTy, 1))), Type::ULongTy); } Constant *ConstantExpr::getPtrPtrFromArrayPtr(Constant *C) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h
Changes in directory llvm/include/llvm/Analysis: ScalarEvolutionExpander.h updated: 1.7 -> 1.8 --- Log message: Change inferred casts to explicit casts. --- Diffs of the changes: (+8 -2) ScalarEvolutionExpander.h | 10 -- 1 files changed, 8 insertions(+), 2 deletions(-) Index: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h diff -u llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:1.7 llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:1.8 --- llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:1.7Sun Nov 26 19:05:09 2006 +++ llvm/include/llvm/Analysis/ScalarEvolutionExpander.hSun Dec 3 20:44:57 2006 @@ -115,12 +115,18 @@ Value *visitTruncateExpr(SCEVTruncateExpr *S) { Value *V = expand(S->getOperand()); - return CastInst::createInferredCast(V, S->getType(), "tmp.", InsertPt); + Instruction::CastOps Opcode = (V->getType()->getPrimitiveSizeInBits() == + S->getType()->getPrimitiveSizeInBits()) ? Instruction::BitCast : + Instruction::Trunc; + return CastInst::create(Opcode, V, S->getType(), "tmp.", InsertPt); } Value *visitZeroExtendExpr(SCEVZeroExtendExpr *S) { Value *V = expandInTy(S->getOperand(),S->getType()->getUnsignedVersion()); - return CastInst::createInferredCast(V, S->getType(), "tmp.", InsertPt); + Instruction::CastOps Opcode = (V->getType()->getPrimitiveSizeInBits() == + S->getType()->getPrimitiveSizeInBits()) ? Instruction::BitCast : + Instruction::ZExt; + return CastInst::create(Opcode, V, S->getType(), "tmp.", InsertPt); } Value *visitAddExpr(SCEVAddExpr *S) { ___ 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
Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.557 -> 1.558 --- Log message: Update call to CastInst::getCastOpcode for its new signature. --- Diffs of the changes: (+2 -1) InstructionCombining.cpp |3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.557 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.558 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.557 Fri Dec 1 18:13:08 2006 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Dec 3 20:48:01 2006 @@ -388,7 +388,8 @@ // If this is another cast that can be eliminated, it isn't codegen either. if (const CastInst *CI = dyn_cast(V)) -if (isEliminableCastPair(CI, CastInst::getCastOpcode(V, Ty), Ty, TD)) +if (isEliminableCastPair(CI, CastInst::getCastOpcode( +V, V->getType()->isSigned(), Ty, Ty->isSigned()), Ty, TD)) 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/include/llvm/Constants.h
Changes in directory llvm/include/llvm: Constants.h updated: 1.98 -> 1.99 --- Log message: For PR950: http://llvm.org/PR950 : Provide an isCompare method for detection of ICmp and FCmp constant expressions. Change interfaces to allow for ICmp and FCmp predicate values. --- Diffs of the changes: (+6 -2) Constants.h |8 ++-- 1 files changed, 6 insertions(+), 2 deletions(-) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.98 llvm/include/llvm/Constants.h:1.99 --- llvm/include/llvm/Constants.h:1.98 Sun Dec 3 20:43:42 2006 +++ llvm/include/llvm/Constants.h Sun Dec 3 23:19:02 2006 @@ -498,7 +498,7 @@ // These private methods are used by the type resolution code to create // ConstantExprs in intermediate forms. static Constant *getTy(const Type *Ty, unsigned Opcode, - Constant *C1, Constant *C2); + Constant *C1, Constant *C2, unsigned short pred = 0); static Constant *getShiftTy(const Type *Ty, unsigned Opcode, Constant *C1, Constant *C2); static Constant *getSelectTy(const Type *Ty, @@ -554,6 +554,9 @@ /// @brief Return true if this is a convert constant expression bool isCast() const; + /// @brief Return true if this is a compare constant expression + bool isCompare() const; + /// Select constant expr /// static Constant *getSelect(Constant *C, Constant *V1, Constant *V2) { @@ -572,7 +575,8 @@ /// ConstantExpr::get - Return a binary or shift operator constant expression, /// folding if possible. /// - static Constant *get(unsigned Opcode, Constant *C1, Constant *C2); + static Constant *get(unsigned Opcode, Constant *C1, Constant *C2, + unsigned short pred = 0); /// ConstantExpr::get* - Return some common constants without having to /// specify the full Instruction::OPCODE identifier. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp
Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.216 -> 1.217 --- Log message: For PR950: http://llvm.org/PR950 : Implement ICmp/FCmp predicate printing for constant expressions --- Diffs of the changes: (+39 -35) AsmWriter.cpp | 74 ++ 1 files changed, 39 insertions(+), 35 deletions(-) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.216 llvm/lib/VMCore/AsmWriter.cpp:1.217 --- llvm/lib/VMCore/AsmWriter.cpp:1.216 Sun Dec 3 00:35:48 2006 +++ llvm/lib/VMCore/AsmWriter.cpp Sun Dec 3 23:19:18 2006 @@ -414,6 +414,39 @@ } } +static const char * getPredicateText(unsigned predicate) { + const char * pred = "unknown"; + switch (predicate) { +case FCmpInst::FCMP_FALSE: pred = "false"; break; +case FCmpInst::FCMP_OEQ: pred = "oeq"; break; +case FCmpInst::FCMP_OGT: pred = "ogt"; break; +case FCmpInst::FCMP_OGE: pred = "oge"; break; +case FCmpInst::FCMP_OLT: pred = "olt"; break; +case FCmpInst::FCMP_OLE: pred = "ole"; break; +case FCmpInst::FCMP_ONE: pred = "one"; break; +case FCmpInst::FCMP_ORD: pred = "ord"; break; +case FCmpInst::FCMP_UNO: pred = "uno"; break; +case FCmpInst::FCMP_UEQ: pred = "ueq"; break; +case FCmpInst::FCMP_UGT: pred = "ugt"; break; +case FCmpInst::FCMP_UGE: pred = "uge"; break; +case FCmpInst::FCMP_ULT: pred = "ult"; break; +case FCmpInst::FCMP_ULE: pred = "ule"; break; +case FCmpInst::FCMP_UNE: pred = "une"; break; +case FCmpInst::FCMP_TRUE: pred = "true"; break; +case ICmpInst::ICMP_EQ:pred = "eq"; break; +case ICmpInst::ICMP_NE:pred = "ne"; break; +case ICmpInst::ICMP_SGT: pred = "sgt"; break; +case ICmpInst::ICMP_SGE: pred = "sge"; break; +case ICmpInst::ICMP_SLT: pred = "slt"; break; +case ICmpInst::ICMP_SLE: pred = "sle"; break; +case ICmpInst::ICMP_UGT: pred = "ugt"; break; +case ICmpInst::ICMP_UGE: pred = "uge"; break; +case ICmpInst::ICMP_ULT: pred = "ult"; break; +case ICmpInst::ICMP_ULE: pred = "ule"; break; + } + return pred; +} + /// @brief Internal constant writer. static void WriteConstantInt(std::ostream &Out, const Constant *CV, bool PrintName, @@ -533,7 +566,10 @@ Out << "undef"; } else if (const ConstantExpr *CE = dyn_cast(CV)) { -Out << CE->getOpcodeName() << " ("; +Out << CE->getOpcodeName(); +if (CE->isCompare()) + Out << " " << getPredicateText(CE->getPredicate()); +Out << " ("; for (User::const_op_iterator OI=CE->op_begin(); OI != CE->op_end(); ++OI) { printTypeInt(Out, (*OI)->getType(), TypeTable); @@ -1127,41 +1163,9 @@ // Print out the compare instruction predicates if (const FCmpInst *FCI = dyn_cast(&I)) { -const char *pred = 0; -switch (FCI->getPredicate()) { - case FCmpInst::FCMP_FALSE: pred = "false"; - case FCmpInst::FCMP_OEQ: pred = "oeq"; - case FCmpInst::FCMP_OGT: pred = "ogt"; - case FCmpInst::FCMP_OGE: pred = "oge"; - case FCmpInst::FCMP_OLT: pred = "olt"; - case FCmpInst::FCMP_OLE: pred = "ole"; - case FCmpInst::FCMP_ONE: pred = "one"; - case FCmpInst::FCMP_ORD: pred = "ord"; - case FCmpInst::FCMP_UNO: pred = "uno"; - case FCmpInst::FCMP_UEQ: pred = "ueq"; - case FCmpInst::FCMP_UGT: pred = "ugt"; - case FCmpInst::FCMP_UGE: pred = "uge"; - case FCmpInst::FCMP_ULT: pred = "ult"; - case FCmpInst::FCMP_ULE: pred = "ule"; - case FCmpInst::FCMP_UNE: pred = "une"; - case FCmpInst::FCMP_TRUE: pred = "true"; -} -Out << " " << pred; +Out << " " << getPredicateText(FCI->getPredicate()); } else if (const ICmpInst *ICI = dyn_cast(&I)) { -const char *pred = 0; -switch (ICI->getPredicate()) { - case ICmpInst::ICMP_EQ:pred = "eq"; - case ICmpInst::ICMP_NE:pred = "ne"; - case ICmpInst::ICMP_SGT: pred = "sgt"; - case ICmpInst::ICMP_SGE: pred = "sge"; - case ICmpInst::ICMP_SLT: pred = "slt"; - case ICmpInst::ICMP_SLE: pred = "sle"; - case ICmpInst::ICMP_UGT: pred = "ugt"; - case ICmpInst::ICMP_UGE: pred = "uge"; - case ICmpInst::ICMP_ULT: pred = "ult"; - case ICmpInst::ICMP_ULE: pred = "ule"; -} -Out << " " << pred; +Out << " " << getPredicateText(ICI->getPredicate()); } // Print out the type of the operands... ___ 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
Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.175 -> 1.176 --- Log message: For PR950: http://llvm.org/PR950 : Fix constant expressions to properly support ICmp and FCmp type expressions. --- Diffs of the changes: (+127 -59) Constants.cpp | 186 +++--- 1 files changed, 127 insertions(+), 59 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.175 llvm/lib/VMCore/Constants.cpp:1.176 --- llvm/lib/VMCore/Constants.cpp:1.175 Sun Dec 3 20:43:42 2006 +++ llvm/lib/VMCore/Constants.cpp Sun Dec 3 23:19:50 2006 @@ -442,6 +442,10 @@ return Instruction::isCast(getOpcode()); } +bool ConstantExpr::isCompare() const { + return getOpcode() == Instruction::ICmp || getOpcode() == Instruction::FCmp; +} + /// ConstantExpr::get* - Return some common constants without having to /// specify the full Instruction::OPCODE identifier. /// @@ -510,23 +514,6 @@ Constant *ConstantExpr::getSetGE(Constant *C1, Constant *C2) { return get(Instruction::SetGE, C1, C2); } -Constant * -ConstantExpr::getICmp(unsigned short pred, Constant* LHS, Constant* RHS) { - assert(LHS->getType() == RHS->getType()); - assert(pred >= ICmpInst::FIRST_ICMP_PREDICATE && - pred <= ICmpInst::LAST_ICMP_PREDICATE && "Invalid ICmp Predicate"); - CompareConstantExpr *Result = -new CompareConstantExpr(Instruction::ICmp, pred, LHS, RHS); - return Result; -} -Constant * -ConstantExpr::getFCmp(unsigned short pred, Constant* LHS, Constant* RHS) { - assert(LHS->getType() == RHS->getType()); - assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && "Invalid ICmp Predicate"); - CompareConstantExpr *Result = -new CompareConstantExpr(Instruction::FCmp, pred, LHS, RHS); - return Result; -} unsigned ConstantExpr::getPredicate() const { assert(getOpcode() == Instruction::FCmp || getOpcode() == Instruction::ICmp); return dynamic_cast(this)->predicate; @@ -1370,41 +1357,68 @@ // ConstantExpr::get() implementations... // -typedef std::pair > ExprMapKeyType; +struct ExprMapKeyType { + explicit ExprMapKeyType(unsigned opc, std::vector ops, + unsigned short pred = 0) : opcode(opc), operands(ops), predicate(pred) { } + unsigned opcode; + std::vector operands; + unsigned short predicate; + bool operator==(const ExprMapKeyType& that) const { +return this->opcode == that.opcode && + this->predicate == that.predicate && + this->operands == that.operands; + } + bool operator<(const ExprMapKeyType & that) const { +return this->opcode < that.opcode || + (this->opcode == that.opcode && this->predicate < that.predicate) || + (this->opcode == that.opcode && this->predicate == that.predicate && + this->operands < that.operands); + } + + bool operator!=(const ExprMapKeyType& that) const { +return !(*this == that); + } +}; namespace llvm { template<> struct ConstantCreator { static ConstantExpr *create(const Type *Ty, const ExprMapKeyType &V, unsigned short pred = 0) { - if (Instruction::isCast(V.first)) -return new UnaryConstantExpr(V.first, V.second[0], Ty); - if ((V.first >= Instruction::BinaryOpsBegin && - V.first < Instruction::BinaryOpsEnd) || - V.first == Instruction::Shl || - V.first == Instruction::LShr || - V.first == Instruction::AShr) -return new BinaryConstantExpr(V.first, V.second[0], V.second[1]); - if (V.first == Instruction::Select) -return new SelectConstantExpr(V.second[0], V.second[1], V.second[2]); - if (V.first == Instruction::ExtractElement) -return new ExtractElementConstantExpr(V.second[0], V.second[1]); - if (V.first == Instruction::InsertElement) -return new InsertElementConstantExpr(V.second[0], V.second[1], - V.second[2]); - if (V.first == Instruction::ShuffleVector) -return new ShuffleVectorConstantExpr(V.second[0], V.second[1], - V.second[2]); - if (V.first == Instruction::ICmp) -return new CompareConstantExpr(Instruction::ICmp, pred, - V.second[0], V.second[1]); - if (V.first == Instruction::FCmp) -return new CompareConstantExpr(Instruction::FCmp, pred, - V.second[0], V.second[1]); - - assert(V.first == Instruction::GetElementPtr && "Invalid ConstantExpr!"); - std::vector IdxList(V.second.begin()+1, V.second.end()); - return new GetElementPtrConstantExpr(V.second[0], IdxList, Ty); + if (Instruction::isCast(V.opcode)) +return new UnaryConstantExpr(V.opcode, V.operands[0], Ty); + if ((V.opcode >= Instruction::BinaryOpsBegin && + V.opcode < Instruction::BinaryOpsEnd) || + V.opcode == Instruction::Shl || + V.opcode == Inst
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.283 -> 1.284 --- Log message: For PR950: http://llvm.org/PR950 : For ICmp and FCmp constant expressions, put the predicate outiside the parentheses to match what llvm-upgrade generates. --- Diffs of the changes: (+7 -7) llvmAsmParser.y | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.283 llvm/lib/AsmParser/llvmAsmParser.y:1.284 --- llvm/lib/AsmParser/llvmAsmParser.y:1.283Sun Dec 3 10:19:43 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Dec 3 23:20:06 2006 @@ -1127,7 +1127,7 @@ UITOFP | SITOFP | FPTOUI | FPTOSI | INTTOPTR | PTRTOINT; ShiftOps : SHL | LSHR | ASHR; IPredicates - : EQ { $$ = ICmpInst::ICMP_EQ; } | NE { $$ = ICmpInst::ICMP_NE; } + : EQ { $$ = ICmpInst::ICMP_EQ; } | NE { $$ = ICmpInst::ICMP_NE; } | SLT { $$ = ICmpInst::ICMP_SLT; } | SGT { $$ = ICmpInst::ICMP_SGT; } | SLE { $$ = ICmpInst::ICMP_SLE; } | SGE { $$ = ICmpInst::ICMP_SGE; } | ULT { $$ = ICmpInst::ICMP_ULT; } | UGT { $$ = ICmpInst::ICMP_UGT; } @@ -1706,15 +1706,15 @@ $$ = ConstantExpr::get($1, $3, $5); CHECK_FOR_ERROR } - | ICMP '(' IPredicates ',' ConstVal ',' ConstVal ')' { -if ($5->getType() != $7->getType()) + | ICMP IPredicates '(' ConstVal ',' ConstVal ')' { +if ($4->getType() != $6->getType()) GEN_ERROR("icmp operand types must match!"); -$$ = ConstantExpr::getICmp($3, $5, $7); +$$ = ConstantExpr::getICmp($2, $4, $6); } - | FCMP '(' FPredicates ',' ConstVal ',' ConstVal ')' { -if ($5->getType() != $7->getType()) + | FCMP FPredicates '(' ConstVal ',' ConstVal ')' { +if ($4->getType() != $6->getType()) GEN_ERROR("fcmp operand types must match!"); -$$ = ConstantExpr::getFCmp($3, $5, $7); +$$ = ConstantExpr::getFCmp($2, $4, $6); } | ShiftOps '(' ConstVal ',' ConstVal ')' { if ($5->getType() != Type::UByteTy) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp
Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.210 -> 1.211 --- Log message: For PR950: http://llvm.org/PR950 : Implement read/write of ICmp and FCmp constant expressions --- Diffs of the changes: (+10 -6) Reader.cpp | 16 ++-- 1 files changed, 10 insertions(+), 6 deletions(-) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.210 llvm/lib/Bytecode/Reader/Reader.cpp:1.211 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.210 Sun Dec 3 11:17:02 2006 +++ llvm/lib/Bytecode/Reader/Reader.cpp Sun Dec 3 23:23:49 2006 @@ -1355,14 +1355,18 @@ return Result; } else if (Opcode == Instruction::ICmp) { if (ArgVec.size() != 2) -error("Invalid ICmp constant expr arguments"); - unsigned short pred = read_vbr_uint(); - return ConstantExpr::getICmp(pred, ArgVec[0], ArgVec[1]); +error("Invalid ICmp constant expr arguments."); + unsigned predicate = read_vbr_uint(); + Constant *Result = ConstantExpr::getICmp(predicate, ArgVec[0], ArgVec[1]); + if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); + return Result; } else if (Opcode == Instruction::FCmp) { if (ArgVec.size() != 2) -error("Invalid FCmp constant expr arguments"); - unsigned short pred = read_vbr_uint(); - return ConstantExpr::getFCmp(pred, ArgVec[0], ArgVec[1]); +error("Invalid FCmp constant expr arguments."); + unsigned predicate = read_vbr_uint(); + Constant *Result = ConstantExpr::getFCmp(predicate, ArgVec[0], ArgVec[1]); + if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); + return Result; } else {// All other 2-operand expressions Constant* Result = ConstantExpr::get(Opcode, ArgVec[0], ArgVec[1]); if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp
Changes in directory llvm/lib/Bytecode/Writer: Writer.cpp updated: 1.132 -> 1.133 --- Log message: For PR950: http://llvm.org/PR950 : Implement read/write of ICmp and FCmp constant expressions --- Diffs of the changes: (+2 -0) Writer.cpp |2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.132 llvm/lib/Bytecode/Writer/Writer.cpp:1.133 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.132 Sun Dec 3 11:17:02 2006 +++ llvm/lib/Bytecode/Writer/Writer.cpp Sun Dec 3 23:23:49 2006 @@ -303,6 +303,8 @@ Slot = Table.getSlot((*OI)->getType()); output_typeid((unsigned)Slot); } +if (CE->isCompare()) + output_vbr((unsigned)CE->getPredicate()); return; } else if (isa(CPV)) { output_vbr(1U); // 1 -> UndefValue constant. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp ConstantFolding.h
Changes in directory llvm/lib/VMCore: ConstantFolding.cpp updated: 1.106 -> 1.107 ConstantFolding.h updated: 1.49 -> 1.50 --- Log message: For PR950: http://llvm.org/PR950 : Implement a stub for folding ICmp and FCmp instructions --- Diffs of the changes: (+9 -0) ConstantFolding.cpp |7 +++ ConstantFolding.h |2 ++ 2 files changed, 9 insertions(+) Index: llvm/lib/VMCore/ConstantFolding.cpp diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.106 llvm/lib/VMCore/ConstantFolding.cpp:1.107 --- llvm/lib/VMCore/ConstantFolding.cpp:1.106 Sun Dec 3 20:45:43 2006 +++ llvm/lib/VMCore/ConstantFolding.cpp Sun Dec 3 23:19:34 2006 @@ -1600,6 +1600,13 @@ return 0; } +Constant *llvm::ConstantFoldCompare( +unsigned opcode, Constant *C1, Constant *C2, unsigned short predicate) +{ + // Place holder for future folding of ICmp and FCmp instructions + return 0; +} + Constant *llvm::ConstantFoldGetElementPtr(const Constant *C, const std::vector &IdxList) { if (IdxList.size() == 0 || Index: llvm/lib/VMCore/ConstantFolding.h diff -u llvm/lib/VMCore/ConstantFolding.h:1.49 llvm/lib/VMCore/ConstantFolding.h:1.50 --- llvm/lib/VMCore/ConstantFolding.h:1.49 Sun Nov 26 19:05:10 2006 +++ llvm/lib/VMCore/ConstantFolding.h Sun Dec 3 23:19:34 2006 @@ -45,6 +45,8 @@ const Constant *Mask); Constant *ConstantFoldBinaryInstruction(unsigned Opcode, const Constant *V1, const Constant *V2); + Constant *ConstantFoldCompare(unsigned opcode, Constant *C1, Constant *C2, +unsigned short predicate); Constant *ConstantFoldGetElementPtr(const Constant *C, const std::vector &IdxList); } // End llvm namespace ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits