[llvm-commits] [llvm-gcc-4.2] r70631 - in /llvm-gcc-4.2/trunk/gcc: config/i386/llvm-i386-target.h config/i386/llvm-i386.cpp llvm-convert.cpp
Duncan Sands
baldrick at free.fr
Sat May 2 10:20:24 PDT 2009
Author: baldrick
Date: Sat May 2 12:20:23 2009
New Revision: 70631
URL: http://llvm.org/viewvc/llvm-project?rev=70631&view=rev
Log:
Implement LLVM_STORE_SCALAR_ARGUMENT and
LLVM_LOAD_SCALAR_ARGUMENT using apints
rather than by loading/storing bytes at
a time. Since the x86 implementation is
not x86 specific, generalize it. I'm not
sure what these routines are supposed to
do exactly, in fact they seem rather hacky,
so I just made sure that the final effect
should be the same as before in all cases
that didn't abort before.
Modified:
llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h
llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h?rev=70631&r1=70630&r2=70631&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h Sat May 2 12:20:23 2009
@@ -223,24 +223,6 @@
llvm_x86_64_aggregate_partially_passed_in_regs((E), (SE)) : \
false)
-/* llvm_store_scalar_argument - Store scalar argument ARGVAL of type
- LLVMTY at location LOC. */
-extern void llvm_x86_store_scalar_argument(Value *Loc, Value *ArgVal,
- const llvm::Type *LLVMTy,
- unsigned RealSize,
- LLVMBuilder &Builder);
-#define LLVM_STORE_SCALAR_ARGUMENT(LOC,ARG,TYPE,SIZE,BUILDER) \
- llvm_x86_store_scalar_argument((LOC),(ARG),(TYPE),(SIZE),(BUILDER))
-
-
-/* llvm_load_scalar_argument - Load value located at LOC. */
-extern Value *llvm_x86_load_scalar_argument(Value *L,
- const llvm::Type *LLVMTy,
- unsigned RealSize,
- LLVMBuilder &Builder);
-#define LLVM_LOAD_SCALAR_ARGUMENT(LOC,TY,SIZE,BUILDER) \
- llvm_x86_load_scalar_argument((LOC),(TY),(SIZE),(BUILDER))
-
#endif /* LLVM_ABI_H */
#endif /* ENABLE_LLVM */
/* LLVM LOCAL end (ENTIRE FILE!) */
Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=70631&r1=70630&r2=70631&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Sat May 2 12:20:23 2009
@@ -1439,53 +1439,6 @@
}
}
-/// llvm_store_scalar_argument - Store scalar argument ARGVAL of type
-/// LLVMTY at location LOC.
-void llvm_x86_store_scalar_argument(Value *Loc, Value *ArgVal,
- const llvm::Type *LLVMTy,
- unsigned RealSize,
- LLVMBuilder &Builder) {
- if (RealSize) {
- // Do byte wise store because actaul argument type does not match LLVMTy.
- Loc = Builder.CreateBitCast(Loc,
- PointerType::getUnqual(llvm::Type::Int8Ty), "bc");
- Value *ShAmt = ConstantInt::get(LLVMTy, 8);
- for (unsigned i = 0; i < RealSize; ++i) {
- Value *AVT = Builder.CreateTrunc(ArgVal, llvm::Type::Int8Ty, "byte");
- Builder.CreateStore(AVT, Loc);
- ArgVal = Builder.CreateLShr(ArgVal, ShAmt, "shft");
- Loc = Builder.CreateGEP(Loc, ConstantInt::get(llvm::Type::Int32Ty, 1),
- "Loc");
- }
- } else {
- // This cast only involves pointers, therefore BitCast.
- Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(LLVMTy), "tmp");
- Builder.CreateStore(ArgVal, Loc);
- }
-}
-
-/// llvm_load_scalar_argument - Load value located at LOC.
-Value *llvm_x86_load_scalar_argument(Value *L,
- const llvm::Type *LLVMTy,
- unsigned RealSize,
- LLVMBuilder &Builder) {
- Value *Loc = NULL;
- L = Builder.CreateBitCast(L, PointerType::getUnqual(llvm::Type::Int8Ty), "bc");
- // Load each byte individually.
- for (unsigned i = 0; i < RealSize; ++i) {
- Value *V = Builder.CreateLoad(L, "val");
- Value *V2 = Builder.CreateZExt(V, LLVMTy);
- if (Loc == NULL)
- Loc = V2;
- else {
- Value *ShAmt = ConstantInt::get(LLVMTy, 8*i);
- Loc = Builder.CreateOr(Loc, Builder.CreateShl(V2, ShAmt, "shl"), "loc");
- }
- L = Builder.CreateGEP(L, ConstantInt::get(llvm::Type::Int32Ty, 1), "gep");
- }
- return Loc;
-}
-
/// llvm_x86_should_pass_aggregate_in_integer_regs - x86-32 is same as the
/// default. x86-64 detects the case where a type is 16 bytes long but
/// only 8 of them are passed, the rest being padding (*size is set to 8
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=70631&r1=70630&r2=70631&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Sat May 2 12:20:23 2009
@@ -209,11 +209,24 @@
const llvm::Type *LLVMTy,
unsigned RealSize,
LLVMBuilder &Builder) {
- assert (RealSize == 0 &&
- "The target should handle this argument!");
- // This cast only involves pointers, therefore BitCast.
- Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(LLVMTy));
- Builder.CreateStore(ArgVal, Loc);
+ if (RealSize) {
+ // Not clear what this is supposed to do on big endian machines...
+ assert(!BYTES_BIG_ENDIAN && "Unsupported case - please report");
+ // Do byte wise store because actual argument type does not match LLVMTy.
+ assert(isa<IntegerType>(ArgVal->getType()) && "Expected an integer value!");
+ const Type *StoreType = IntegerType::get(RealSize * 8);
+ Loc = Builder.CreateBitCast(Loc, StoreType->getPointerTo());
+ if (ArgVal->getType()->getPrimitiveSizeInBits() >=
+ StoreType->getPrimitiveSizeInBits())
+ ArgVal = Builder.CreateTrunc(ArgVal, StoreType);
+ else
+ ArgVal = Builder.CreateZExt(ArgVal, StoreType);
+ Builder.CreateStore(ArgVal, Loc);
+ } else {
+ // This cast only involves pointers, therefore BitCast.
+ Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(LLVMTy));
+ Builder.CreateStore(ArgVal, Loc);
+ }
}
#ifndef LLVM_STORE_SCALAR_ARGUMENT
@@ -2254,8 +2267,20 @@
const llvm::Type *LLVMTy,
unsigned RealSize,
LLVMBuilder &Builder) {
- assert (0 && "The target should override this routine!");
- return NULL;
+ if (!RealSize)
+ return UndefValue::get(LLVMTy);
+
+ // Not clear what this is supposed to do on big endian machines...
+ assert(!BYTES_BIG_ENDIAN && "Unsupported case - please report");
+ assert(isa<IntegerType>(LLVMTy) && "Expected an integer value!");
+ const Type *LoadType = IntegerType::get(RealSize * 8);
+ L = Builder.CreateBitCast(L, LoadType->getPointerTo());
+ Value *Val = Builder.CreateLoad(L);
+ if (LoadType->getPrimitiveSizeInBits() >= LLVMTy->getPrimitiveSizeInBits())
+ Val = Builder.CreateTrunc(Val, LLVMTy);
+ else
+ Val = Builder.CreateZExt(Val, LLVMTy);
+ return Val;
}
#ifndef LLVM_LOAD_SCALAR_ARGUMENT
More information about the llvm-commits
mailing list