Commit ac230129 by Nicolas Capens

Abstract llvm::Type usage.

Bug swiftshader:10 Change-Id: I86b80cb03ff48ff7273aaf23a8e4995b3436f825 Reviewed-on: https://swiftshader-review.googlesource.com/7274Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 0e33ae3e
...@@ -67,7 +67,7 @@ Routine *routine = function(L"one"); ...@@ -67,7 +67,7 @@ Routine *routine = function(L"one");
Finally, we can obtain the function pointer to the entry point of the routine, and call it: Finally, we can obtain the function pointer to the entry point of the routine, and call it:
```C++ ```C++
int (*callable)() = (int(*)())function.getEntry(); int (*callable)() = (int(*)())routine->getEntry();
int result = callable(); int result = callable();
assert(result == 1); assert(result == 1);
......
...@@ -75,6 +75,20 @@ namespace sw ...@@ -75,6 +75,20 @@ namespace sw
Optimization optimization[10] = {InstructionCombining, Disabled}; Optimization optimization[10] = {InstructionCombining, Disabled};
class Type : public llvm::Type
{
};
inline Type *T(llvm::Type *t)
{
return reinterpret_cast<Type*>(t);
}
inline std::vector<llvm::Type*> &T(std::vector<Type*> &t)
{
return reinterpret_cast<std::vector<llvm::Type*>&>(t);
}
Nucleus::Nucleus() Nucleus::Nucleus()
{ {
codegenMutex.lock(); // Reactor and LLVM are currently not thread safe codegenMutex.lock(); // Reactor and LLVM are currently not thread safe
...@@ -143,7 +157,7 @@ namespace sw ...@@ -143,7 +157,7 @@ namespace sw
{ {
if(::builder->GetInsertBlock()->empty() || !::builder->GetInsertBlock()->back().isTerminator()) if(::builder->GetInsertBlock()->empty() || !::builder->GetInsertBlock()->back().isTerminator())
{ {
Type *type = ::function->getReturnType(); llvm::Type *type = ::function->getReturnType();
if(type->isVoidTy()) if(type->isVoidTy())
{ {
...@@ -265,9 +279,9 @@ namespace sw ...@@ -265,9 +279,9 @@ namespace sw
return *pred_begin(basicBlock); return *pred_begin(basicBlock);
} }
void Nucleus::createFunction(llvm::Type *ReturnType, std::vector<llvm::Type*> &Params) void Nucleus::createFunction(Type *ReturnType, std::vector<Type*> &Params)
{ {
llvm::FunctionType *functionType = llvm::FunctionType::get(ReturnType, Params, false); llvm::FunctionType *functionType = llvm::FunctionType::get(ReturnType, T(Params), false);
::function = llvm::Function::Create(functionType, llvm::GlobalValue::InternalLinkage, "", ::module); ::function = llvm::Function::Create(functionType, llvm::GlobalValue::InternalLinkage, "", ::module);
::function->setCallingConv(llvm::CallingConv::C); ::function->setCallingConv(llvm::CallingConv::C);
...@@ -714,7 +728,7 @@ namespace sw ...@@ -714,7 +728,7 @@ namespace sw
return shuffle; return shuffle;
} }
llvm::Constant *Nucleus::createConstantPointer(const void *address, llvm::Type *Ty, bool isConstant, unsigned int Align) llvm::Constant *Nucleus::createConstantPointer(const void *address, Type *Ty, bool isConstant, unsigned int Align)
{ {
const GlobalValue *existingGlobal = ::executionEngine->getGlobalValueAtAddress(const_cast<void*>(address)); // FIXME: Const const GlobalValue *existingGlobal = ::executionEngine->getGlobalValueAtAddress(const_cast<void*>(address)); // FIXME: Const
...@@ -723,7 +737,8 @@ namespace sw ...@@ -723,7 +737,8 @@ namespace sw
return (llvm::Constant*)existingGlobal; return (llvm::Constant*)existingGlobal;
} }
GlobalValue *global = new GlobalVariable(*::module, Ty, isConstant, GlobalValue::ExternalLinkage, 0, ""); llvm::GlobalValue *global = new llvm::GlobalVariable(*::module, Ty, isConstant, llvm::GlobalValue::ExternalLinkage, 0, "");
global->setAlignment(Align); global->setAlignment(Align);
::executionEngine->addGlobalMapping(global, const_cast<void*>(address)); ::executionEngine->addGlobalMapping(global, const_cast<void*>(address));
...@@ -731,12 +746,12 @@ namespace sw ...@@ -731,12 +746,12 @@ namespace sw
return global; return global;
} }
llvm::Type *Nucleus::getPointerType(llvm::Type *ElementType) Type *Nucleus::getPointerType(Type *ElementType)
{ {
return llvm::PointerType::get(ElementType, 0); return T(llvm::PointerType::get(ElementType, 0));
} }
llvm::Constant *Nucleus::createNullValue(llvm::Type *Ty) llvm::Constant *Nucleus::createNullValue(Type *Ty)
{ {
return llvm::Constant::getNullValue(Ty); return llvm::Constant::getNullValue(Ty);
} }
...@@ -786,7 +801,7 @@ namespace sw ...@@ -786,7 +801,7 @@ namespace sw
return ConstantFP::get(Float::getType(), x); return ConstantFP::get(Float::getType(), x);
} }
llvm::Value *Nucleus::createNullPointer(llvm::Type *Ty) llvm::Value *Nucleus::createNullPointer(Type *Ty)
{ {
return llvm::ConstantPointerNull::get(llvm::PointerType::get(Ty, 0)); return llvm::ConstantPointerNull::get(llvm::PointerType::get(Ty, 0));
} }
...@@ -798,10 +813,10 @@ namespace sw ...@@ -798,10 +813,10 @@ namespace sw
Type *Void::getType() Type *Void::getType()
{ {
return Type::getVoidTy(*::context); return T(llvm::Type::getVoidTy(*::context));
} }
LValue::LValue(llvm::Type *type, int arraySize) LValue::LValue(Type *type, int arraySize)
{ {
address = Nucleus::allocateStackVariable(type, arraySize); address = Nucleus::allocateStackVariable(type, arraySize);
} }
...@@ -834,7 +849,7 @@ namespace sw ...@@ -834,7 +849,7 @@ namespace sw
Type *MMX::getType() Type *MMX::getType()
{ {
return Type::getX86_MMXTy(*::context); return T(llvm::Type::getX86_MMXTy(*::context));
} }
Bool::Bool(Argument<Bool> argument) Bool::Bool(Argument<Bool> argument)
...@@ -908,7 +923,7 @@ namespace sw ...@@ -908,7 +923,7 @@ namespace sw
Type *Bool::getType() Type *Bool::getType()
{ {
return Type::getInt1Ty(*::context); return T(llvm::Type::getInt1Ty(*::context));
} }
Byte::Byte(Argument<Byte> argument) Byte::Byte(Argument<Byte> argument)
...@@ -1174,7 +1189,7 @@ namespace sw ...@@ -1174,7 +1189,7 @@ namespace sw
Type *Byte::getType() Type *Byte::getType()
{ {
return Type::getInt8Ty(*::context); return T(llvm::Type::getInt8Ty(*::context));
} }
SByte::SByte(Argument<SByte> argument) SByte::SByte(Argument<SByte> argument)
...@@ -1428,7 +1443,7 @@ namespace sw ...@@ -1428,7 +1443,7 @@ namespace sw
Type *SByte::getType() Type *SByte::getType()
{ {
return Type::getInt8Ty(*::context); return T(llvm::Type::getInt8Ty(*::context));
} }
Short::Short(Argument<Short> argument) Short::Short(Argument<Short> argument)
...@@ -1675,7 +1690,7 @@ namespace sw ...@@ -1675,7 +1690,7 @@ namespace sw
Type *Short::getType() Type *Short::getType()
{ {
return Type::getInt16Ty(*::context); return T(llvm::Type::getInt16Ty(*::context));
} }
UShort::UShort(Argument<UShort> argument) UShort::UShort(Argument<UShort> argument)
...@@ -1929,13 +1944,13 @@ namespace sw ...@@ -1929,13 +1944,13 @@ namespace sw
Type *UShort::getType() Type *UShort::getType()
{ {
return Type::getInt16Ty(*::context); return T(llvm::Type::getInt16Ty(*::context));
} }
Type *Byte4::getType() Type *Byte4::getType()
{ {
#if 0 #if 0
return VectorType::get(Byte::getType(), 4); return T(VectorType::get(Byte::getType(), 4));
#else #else
return UInt::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block return UInt::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block
#endif #endif
...@@ -1944,7 +1959,7 @@ namespace sw ...@@ -1944,7 +1959,7 @@ namespace sw
Type *SByte4::getType() Type *SByte4::getType()
{ {
#if 0 #if 0
return VectorType::get(SByte::getType(), 4); return T(VectorType::get(SByte::getType(), 4));
#else #else
return Int::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block return Int::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block
#endif #endif
...@@ -2283,7 +2298,7 @@ namespace sw ...@@ -2283,7 +2298,7 @@ namespace sw
} }
else else
{ {
return VectorType::get(Byte::getType(), 8); return T(VectorType::get(Byte::getType(), 8));
} }
} }
...@@ -2591,7 +2606,7 @@ namespace sw ...@@ -2591,7 +2606,7 @@ namespace sw
} }
else else
{ {
return VectorType::get(SByte::getType(), 8); return T(VectorType::get(SByte::getType(), 8));
} }
} }
...@@ -2643,12 +2658,12 @@ namespace sw ...@@ -2643,12 +2658,12 @@ namespace sw
Type *Byte16::getType() Type *Byte16::getType()
{ {
return VectorType::get(Byte::getType(), 16); return T(VectorType::get(Byte::getType(), 16));
} }
Type *SByte16::getType() Type *SByte16::getType()
{ {
return VectorType::get(SByte::getType(), 16); return T( VectorType::get(SByte::getType(), 16));
} }
Short4::Short4(RValue<Int> cast) Short4::Short4(RValue<Int> cast)
...@@ -3210,7 +3225,7 @@ namespace sw ...@@ -3210,7 +3225,7 @@ namespace sw
} }
else else
{ {
return VectorType::get(Short::getType(), 4); return T(VectorType::get(Short::getType(), 4));
} }
} }
...@@ -3400,7 +3415,6 @@ namespace sw ...@@ -3400,7 +3415,6 @@ namespace sw
} }
} }
RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs) RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs)
{ {
if(CPUID::supportsMMX2()) if(CPUID::supportsMMX2())
...@@ -3516,7 +3530,7 @@ namespace sw ...@@ -3516,7 +3530,7 @@ namespace sw
} }
else else
{ {
return VectorType::get(UShort::getType(), 4); return T(VectorType::get(UShort::getType(), 4));
} }
} }
...@@ -3610,7 +3624,7 @@ namespace sw ...@@ -3610,7 +3624,7 @@ namespace sw
Type *Short8::getType() Type *Short8::getType()
{ {
return VectorType::get(Short::getType(), 8); return T(VectorType::get(Short::getType(), 8));
} }
UShort8::UShort8(unsigned short c0, unsigned short c1, unsigned short c2, unsigned short c3, unsigned short c4, unsigned short c5, unsigned short c6, unsigned short c7) UShort8::UShort8(unsigned short c0, unsigned short c1, unsigned short c2, unsigned short c3, unsigned short c4, unsigned short c5, unsigned short c6, unsigned short c7)
...@@ -3777,7 +3791,7 @@ namespace sw ...@@ -3777,7 +3791,7 @@ namespace sw
Type *UShort8::getType() Type *UShort8::getType()
{ {
return VectorType::get(UShort::getType(), 8); return T(VectorType::get(UShort::getType(), 8));
} }
Int::Int(Argument<Int> argument) Int::Int(Argument<Int> argument)
...@@ -4131,13 +4145,11 @@ namespace sw ...@@ -4131,13 +4145,11 @@ namespace sw
Type *Int::getType() Type *Int::getType()
{ {
return Type::getInt32Ty(*::context); return T(llvm::Type::getInt32Ty(*::context));
} }
Long::Long(RValue<Int> cast) Long::Long(RValue<Int> cast)
{ {
Value *integer = Nucleus::createSExt(cast.value, Long::getType()); Value *integer = Nucleus::createSExt(cast.value, Long::getType());
storeValue(integer); storeValue(integer);
...@@ -4214,7 +4226,7 @@ namespace sw ...@@ -4214,7 +4226,7 @@ namespace sw
Type *Long::getType() Type *Long::getType()
{ {
return Type::getInt64Ty(*::context); return T(llvm::Type::getInt64Ty(*::context));
} }
Long1::Long1(const RValue<UInt> cast) Long1::Long1(const RValue<UInt> cast)
...@@ -4238,7 +4250,7 @@ namespace sw ...@@ -4238,7 +4250,7 @@ namespace sw
} }
else else
{ {
return VectorType::get(Long::getType(), 1); return T(VectorType::get(Long::getType(), 1));
} }
} }
...@@ -4255,7 +4267,7 @@ namespace sw ...@@ -4255,7 +4267,7 @@ namespace sw
Type *Long2::getType() Type *Long2::getType()
{ {
return VectorType::get(Long::getType(), 2); return T(VectorType::get(Long::getType(), 2));
} }
UInt::UInt(Argument<UInt> argument) UInt::UInt(Argument<UInt> argument)
...@@ -4600,7 +4612,7 @@ namespace sw ...@@ -4600,7 +4612,7 @@ namespace sw
Type *UInt::getType() Type *UInt::getType()
{ {
return Type::getInt32Ty(*::context); return T(llvm::Type::getInt32Ty(*::context));
} }
// Int2::Int2(RValue<Int> cast) // Int2::Int2(RValue<Int> cast)
...@@ -4681,7 +4693,7 @@ namespace sw ...@@ -4681,7 +4693,7 @@ namespace sw
shuffle[0] = Nucleus::createConstantInt(0); shuffle[0] = Nucleus::createConstantInt(0);
shuffle[1] = Nucleus::createConstantInt(1); shuffle[1] = Nucleus::createConstantInt(1);
Value *packed = Nucleus::createShuffleVector(Nucleus::createBitCast(lo.value, VectorType::get(Int::getType(), 1)), Nucleus::createBitCast(hi.value, VectorType::get(Int::getType(), 1)), Nucleus::createConstantVector(shuffle, 2)); Value *packed = Nucleus::createShuffleVector(Nucleus::createBitCast(lo.value, T(VectorType::get(Int::getType(), 1))), Nucleus::createBitCast(hi.value, T(VectorType::get(Int::getType(), 1))), Nucleus::createConstantVector(shuffle, 2));
storeValue(Nucleus::createBitCast(packed, Int2::getType())); storeValue(Nucleus::createBitCast(packed, Int2::getType()));
} }
...@@ -4941,7 +4953,7 @@ namespace sw ...@@ -4941,7 +4953,7 @@ namespace sw
{ {
if(i == 0) if(i == 0)
{ {
return RValue<Int>(Nucleus::createExtractElement(Nucleus::createBitCast(val.value, VectorType::get(Int::getType(), 2)), 0)); return RValue<Int>(Nucleus::createExtractElement(Nucleus::createBitCast(val.value, T(VectorType::get(Int::getType(), 2))), 0));
} }
else else
{ {
...@@ -4954,7 +4966,7 @@ namespace sw ...@@ -4954,7 +4966,7 @@ namespace sw
RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i) RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i)
{ {
return RValue<Int2>(Nucleus::createBitCast(Nucleus::createInsertElement(Nucleus::createBitCast(val.value, VectorType::get(Int::getType(), 2)), element.value, i), Int2::getType())); return RValue<Int2>(Nucleus::createBitCast(Nucleus::createInsertElement(Nucleus::createBitCast(val.value, T(VectorType::get(Int::getType(), 2))), element.value, i), Int2::getType()));
} }
Type *Int2::getType() Type *Int2::getType()
...@@ -4965,7 +4977,7 @@ namespace sw ...@@ -4965,7 +4977,7 @@ namespace sw
} }
else else
{ {
return VectorType::get(Int::getType(), 2); return T(VectorType::get(Int::getType(), 2));
} }
} }
...@@ -5225,7 +5237,7 @@ namespace sw ...@@ -5225,7 +5237,7 @@ namespace sw
} }
else else
{ {
return VectorType::get(UInt::getType(), 2); return T(VectorType::get(UInt::getType(), 2));
} }
} }
...@@ -5789,7 +5801,7 @@ namespace sw ...@@ -5789,7 +5801,7 @@ namespace sw
Type *Int4::getType() Type *Int4::getType()
{ {
return VectorType::get(Int::getType(), 4); return T(VectorType::get(Int::getType(), 4));
} }
UInt4::UInt4(RValue<Float4> cast) UInt4::UInt4(RValue<Float4> cast)
...@@ -6130,7 +6142,7 @@ namespace sw ...@@ -6130,7 +6142,7 @@ namespace sw
Type *UInt4::getType() Type *UInt4::getType()
{ {
return VectorType::get(UInt::getType(), 4); return T(VectorType::get(UInt::getType(), 4));
} }
Float::Float(RValue<Int> cast) Float::Float(RValue<Int> cast)
...@@ -6371,7 +6383,7 @@ namespace sw ...@@ -6371,7 +6383,7 @@ namespace sw
Type *Float::getType() Type *Float::getType()
{ {
return Type::getFloatTy(*::context); return T(llvm::Type::getFloatTy(*::context));
} }
Float2::Float2(RValue<Float4> cast) Float2::Float2(RValue<Float4> cast)
...@@ -6387,7 +6399,7 @@ namespace sw ...@@ -6387,7 +6399,7 @@ namespace sw
Type *Float2::getType() Type *Float2::getType()
{ {
return VectorType::get(Float::getType(), 2); return T(VectorType::get(Float::getType(), 2));
} }
Float4::Float4(RValue<Byte4> cast) Float4::Float4(RValue<Byte4> cast)
...@@ -6900,7 +6912,7 @@ namespace sw ...@@ -6900,7 +6912,7 @@ namespace sw
Type *Float4::getType() Type *Float4::getType()
{ {
return VectorType::get(Float::getType(), 4); return T(VectorType::get(Float::getType(), 4));
} }
RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset) RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset)
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
namespace llvm namespace llvm
{ {
class Type;
class Value; class Value;
class Constant; class Constant;
class BasicBlock; class BasicBlock;
...@@ -38,6 +37,8 @@ namespace llvm ...@@ -38,6 +37,8 @@ namespace llvm
namespace sw namespace sw
{ {
class Type;
enum Optimization enum Optimization
{ {
Disabled = 0, Disabled = 0,
...@@ -69,13 +70,13 @@ namespace sw ...@@ -69,13 +70,13 @@ namespace sw
Routine *acquireRoutine(const wchar_t *name, bool runOptimizations = true); Routine *acquireRoutine(const wchar_t *name, bool runOptimizations = true);
static llvm::Value *allocateStackVariable(llvm::Type *type, int arraySize = 0); static llvm::Value *allocateStackVariable(Type *type, int arraySize = 0);
static llvm::BasicBlock *createBasicBlock(); static llvm::BasicBlock *createBasicBlock();
static llvm::BasicBlock *getInsertBlock(); static llvm::BasicBlock *getInsertBlock();
static void setInsertBlock(llvm::BasicBlock *basicBlock); static void setInsertBlock(llvm::BasicBlock *basicBlock);
static llvm::BasicBlock *getPredecessor(llvm::BasicBlock *basicBlock); static llvm::BasicBlock *getPredecessor(llvm::BasicBlock *basicBlock);
static void createFunction(llvm::Type *ReturnType, std::vector<llvm::Type*> &Params); static void createFunction(Type *ReturnType, std::vector<Type*> &Params);
static llvm::Value *getArgument(unsigned int index); static llvm::Value *getArgument(unsigned int index);
// Terminators // Terminators
...@@ -117,18 +118,18 @@ namespace sw ...@@ -117,18 +118,18 @@ namespace sw
static llvm::Value *createAtomicAdd(llvm::Value *ptr, llvm::Value *value); static llvm::Value *createAtomicAdd(llvm::Value *ptr, llvm::Value *value);
// Cast/Conversion Operators // Cast/Conversion Operators
static llvm::Value *createTrunc(llvm::Value *V, llvm::Type *destType); static llvm::Value *createTrunc(llvm::Value *V, Type *destType);
static llvm::Value *createZExt(llvm::Value *V, llvm::Type *destType); static llvm::Value *createZExt(llvm::Value *V, Type *destType);
static llvm::Value *createSExt(llvm::Value *V, llvm::Type *destType); static llvm::Value *createSExt(llvm::Value *V, Type *destType);
static llvm::Value *createFPToSI(llvm::Value *V, llvm::Type *destType); static llvm::Value *createFPToSI(llvm::Value *V, Type *destType);
static llvm::Value *createUIToFP(llvm::Value *V, llvm::Type *destType); static llvm::Value *createUIToFP(llvm::Value *V, Type *destType);
static llvm::Value *createSIToFP(llvm::Value *V, llvm::Type *destType); static llvm::Value *createSIToFP(llvm::Value *V, Type *destType);
static llvm::Value *createFPTrunc(llvm::Value *V, llvm::Type *destType); static llvm::Value *createFPTrunc(llvm::Value *V, Type *destType);
static llvm::Value *createFPExt(llvm::Value *V, llvm::Type *destType); static llvm::Value *createFPExt(llvm::Value *V, Type *destType);
static llvm::Value *createPtrToInt(llvm::Value *V, llvm::Type *destType); static llvm::Value *createPtrToInt(llvm::Value *V, Type *destType);
static llvm::Value *createIntToPtr(llvm::Value *V, llvm::Type *destType); static llvm::Value *createIntToPtr(llvm::Value *V, Type *destType);
static llvm::Value *createBitCast(llvm::Value *V, llvm::Type *destType); static llvm::Value *createBitCast(llvm::Value *V, Type *destType);
static llvm::Value *createIntCast(llvm::Value *V, llvm::Type *destType, bool isSigned); static llvm::Value *createIntCast(llvm::Value *V, Type *destType, bool isSigned);
// Compare instructions // Compare instructions
static llvm::Value *createICmpEQ(llvm::Value *lhs, llvm::Value *rhs); static llvm::Value *createICmpEQ(llvm::Value *lhs, llvm::Value *rhs);
...@@ -179,7 +180,7 @@ namespace sw ...@@ -179,7 +180,7 @@ namespace sw
static llvm::Value *createMask(llvm::Value *lhs, llvm::Value *rhs, unsigned char select); static llvm::Value *createMask(llvm::Value *lhs, llvm::Value *rhs, unsigned char select);
// Constant values // Constant values
static llvm::Constant *createNullValue(llvm::Type *Ty); static llvm::Constant *createNullValue(Type *Ty);
static llvm::Constant *createConstantInt(int64_t i); static llvm::Constant *createConstantInt(int64_t i);
static llvm::Constant *createConstantInt(int i); static llvm::Constant *createConstantInt(int i);
static llvm::Constant *createConstantInt(unsigned int i); static llvm::Constant *createConstantInt(unsigned int i);
...@@ -189,11 +190,11 @@ namespace sw ...@@ -189,11 +190,11 @@ namespace sw
static llvm::Constant *createConstantShort(short i); static llvm::Constant *createConstantShort(short i);
static llvm::Constant *createConstantShort(unsigned short i); static llvm::Constant *createConstantShort(unsigned short i);
static llvm::Constant *createConstantFloat(float x); static llvm::Constant *createConstantFloat(float x);
static llvm::Value *createNullPointer(llvm::Type *Ty); static llvm::Value *createNullPointer(Type *Ty);
static llvm::Value *createConstantVector(llvm::Constant *const *Vals, unsigned NumVals); static llvm::Value *createConstantVector(llvm::Constant *const *Vals, unsigned NumVals);
static llvm::Constant *createConstantPointer(const void *external, llvm::Type *Ty, bool isConstant, unsigned int Align); static llvm::Constant *createConstantPointer(const void *external, Type *Ty, bool isConstant, unsigned int Align);
static llvm::Type *getPointerType(llvm::Type *ElementType); static Type *getPointerType(Type *ElementType);
private: private:
void optimize(); void optimize();
...@@ -231,7 +232,7 @@ namespace sw ...@@ -231,7 +232,7 @@ namespace sw
class Void class Void
{ {
public: public:
static llvm::Type *getType(); static Type *getType();
static bool isVoid() static bool isVoid()
{ {
...@@ -250,7 +251,7 @@ namespace sw ...@@ -250,7 +251,7 @@ namespace sw
class LValue class LValue
{ {
public: public:
LValue(llvm::Type *type, int arraySize = 0); LValue(Type *type, int arraySize = 0);
static bool isVoid() static bool isVoid()
{ {
...@@ -371,7 +372,7 @@ namespace sw ...@@ -371,7 +372,7 @@ namespace sw
RValue<Bool> operator=(const Bool &rhs) const; RValue<Bool> operator=(const Bool &rhs) const;
RValue<Bool> operator=(const Reference<Bool> &rhs) const; RValue<Bool> operator=(const Reference<Bool> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<Bool> operator!(RValue<Bool> val); RValue<Bool> operator!(RValue<Bool> val);
...@@ -399,7 +400,7 @@ namespace sw ...@@ -399,7 +400,7 @@ namespace sw
RValue<Byte> operator=(const Byte &rhs) const; RValue<Byte> operator=(const Byte &rhs) const;
RValue<Byte> operator=(const Reference<Byte> &rhs) const; RValue<Byte> operator=(const Reference<Byte> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs); RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs);
...@@ -455,7 +456,7 @@ namespace sw ...@@ -455,7 +456,7 @@ namespace sw
RValue<SByte> operator=(const SByte &rhs) const; RValue<SByte> operator=(const SByte &rhs) const;
RValue<SByte> operator=(const Reference<SByte> &rhs) const; RValue<SByte> operator=(const Reference<SByte> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs); RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs);
...@@ -510,7 +511,7 @@ namespace sw ...@@ -510,7 +511,7 @@ namespace sw
RValue<Short> operator=(const Short &rhs) const; RValue<Short> operator=(const Short &rhs) const;
RValue<Short> operator=(const Reference<Short> &rhs) const; RValue<Short> operator=(const Reference<Short> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs); RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs);
...@@ -566,7 +567,7 @@ namespace sw ...@@ -566,7 +567,7 @@ namespace sw
RValue<UShort> operator=(const UShort &rhs) const; RValue<UShort> operator=(const UShort &rhs) const;
RValue<UShort> operator=(const Reference<UShort> &rhs) const; RValue<UShort> operator=(const Reference<UShort> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs); RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs);
...@@ -616,7 +617,7 @@ namespace sw ...@@ -616,7 +617,7 @@ namespace sw
// RValue<Byte4> operator=(const Byte4 &rhs) const; // RValue<Byte4> operator=(const Byte4 &rhs) const;
// RValue<Byte4> operator=(const Reference<Byte4> &rhs) const; // RValue<Byte4> operator=(const Reference<Byte4> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
// RValue<Byte4> operator+(RValue<Byte4> lhs, RValue<Byte4> rhs); // RValue<Byte4> operator+(RValue<Byte4> lhs, RValue<Byte4> rhs);
...@@ -660,7 +661,7 @@ namespace sw ...@@ -660,7 +661,7 @@ namespace sw
// RValue<SByte4> operator=(const SByte4 &rhs) const; // RValue<SByte4> operator=(const SByte4 &rhs) const;
// RValue<SByte4> operator=(const Reference<SByte4> &rhs) const; // RValue<SByte4> operator=(const Reference<SByte4> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
// RValue<SByte4> operator+(RValue<SByte4> lhs, RValue<SByte4> rhs); // RValue<SByte4> operator+(RValue<SByte4> lhs, RValue<SByte4> rhs);
...@@ -705,7 +706,7 @@ namespace sw ...@@ -705,7 +706,7 @@ namespace sw
RValue<Byte8> operator=(const Byte8 &rhs) const; RValue<Byte8> operator=(const Byte8 &rhs) const;
RValue<Byte8> operator=(const Reference<Byte8> &rhs) const; RValue<Byte8> operator=(const Reference<Byte8> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs); RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs);
...@@ -759,7 +760,7 @@ namespace sw ...@@ -759,7 +760,7 @@ namespace sw
RValue<SByte8> operator=(const SByte8 &rhs) const; RValue<SByte8> operator=(const SByte8 &rhs) const;
RValue<SByte8> operator=(const Reference<SByte8> &rhs) const; RValue<SByte8> operator=(const Reference<SByte8> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs); RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs);
...@@ -811,7 +812,7 @@ namespace sw ...@@ -811,7 +812,7 @@ namespace sw
RValue<Byte16> operator=(const Byte16 &rhs) const; RValue<Byte16> operator=(const Byte16 &rhs) const;
RValue<Byte16> operator=(const Reference<Byte16> &rhs) const; RValue<Byte16> operator=(const Reference<Byte16> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
// RValue<Byte16> operator+(RValue<Byte16> lhs, RValue<Byte16> rhs); // RValue<Byte16> operator+(RValue<Byte16> lhs, RValue<Byte16> rhs);
...@@ -855,7 +856,7 @@ namespace sw ...@@ -855,7 +856,7 @@ namespace sw
// RValue<SByte16> operator=(const SByte16 &rhs) const; // RValue<SByte16> operator=(const SByte16 &rhs) const;
// RValue<SByte16> operator=(const Reference<SByte16> &rhs) const; // RValue<SByte16> operator=(const Reference<SByte16> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
// RValue<SByte16> operator+(RValue<SByte16> lhs, RValue<SByte16> rhs); // RValue<SByte16> operator+(RValue<SByte16> lhs, RValue<SByte16> rhs);
...@@ -911,7 +912,7 @@ namespace sw ...@@ -911,7 +912,7 @@ namespace sw
RValue<Short4> operator=(const UShort4 &rhs) const; RValue<Short4> operator=(const UShort4 &rhs) const;
RValue<Short4> operator=(const Reference<UShort4> &rhs) const; RValue<Short4> operator=(const Reference<UShort4> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs); RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs);
...@@ -991,7 +992,7 @@ namespace sw ...@@ -991,7 +992,7 @@ namespace sw
RValue<UShort4> operator=(const Short4 &rhs) const; RValue<UShort4> operator=(const Short4 &rhs) const;
RValue<UShort4> operator=(const Reference<Short4> &rhs) const; RValue<UShort4> operator=(const Reference<Short4> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs); RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs);
...@@ -1048,7 +1049,7 @@ namespace sw ...@@ -1048,7 +1049,7 @@ namespace sw
// RValue<Short8> operator=(const Short8 &rhs) const; // RValue<Short8> operator=(const Short8 &rhs) const;
// RValue<Short8> operator=(const Reference<Short8> &rhs) const; // RValue<Short8> operator=(const Reference<Short8> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs); RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs);
...@@ -1105,7 +1106,7 @@ namespace sw ...@@ -1105,7 +1106,7 @@ namespace sw
RValue<UShort8> operator=(const UShort8 &rhs) const; RValue<UShort8> operator=(const UShort8 &rhs) const;
RValue<UShort8> operator=(const Reference<UShort8> &rhs) const; RValue<UShort8> operator=(const Reference<UShort8> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs); RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs);
...@@ -1177,7 +1178,7 @@ namespace sw ...@@ -1177,7 +1178,7 @@ namespace sw
RValue<Int> operator=(const Reference<Int> &rhs) const; RValue<Int> operator=(const Reference<Int> &rhs) const;
RValue<Int> operator=(const Reference<UInt> &rhs) const; RValue<Int> operator=(const Reference<UInt> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs); RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs);
...@@ -1247,7 +1248,7 @@ namespace sw ...@@ -1247,7 +1248,7 @@ namespace sw
// RValue<Long> operator=(const ULong &rhs) const; // RValue<Long> operator=(const ULong &rhs) const;
// RValue<Long> operator=(const Reference<ULong> &rhs) const; // RValue<Long> operator=(const Reference<ULong> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs); RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs);
...@@ -1315,7 +1316,7 @@ namespace sw ...@@ -1315,7 +1316,7 @@ namespace sw
// RValue<Long1> operator=(const ULong1 &rhs) const; // RValue<Long1> operator=(const ULong1 &rhs) const;
// RValue<Long1> operator=(const Reference<ULong1> &rhs) const; // RValue<Long1> operator=(const Reference<ULong1> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
// RValue<Long1> operator+(RValue<Long1> lhs, RValue<Long1> rhs); // RValue<Long1> operator+(RValue<Long1> lhs, RValue<Long1> rhs);
...@@ -1370,7 +1371,7 @@ namespace sw ...@@ -1370,7 +1371,7 @@ namespace sw
// RValue<Long2> operator=(const Long2 &rhs) const; // RValue<Long2> operator=(const Long2 &rhs) const;
// RValue<Long2> operator=(const Reference<Long2 &rhs) const; // RValue<Long2> operator=(const Reference<Long2 &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
// RValue<Long2> operator+(RValue<Long2> lhs, RValue<Long2> rhs); // RValue<Long2> operator+(RValue<Long2> lhs, RValue<Long2> rhs);
...@@ -1444,7 +1445,7 @@ namespace sw ...@@ -1444,7 +1445,7 @@ namespace sw
RValue<UInt> operator=(const Reference<UInt> &rhs) const; RValue<UInt> operator=(const Reference<UInt> &rhs) const;
RValue<UInt> operator=(const Reference<Int> &rhs) const; RValue<UInt> operator=(const Reference<Int> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs); RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs);
...@@ -1503,7 +1504,7 @@ namespace sw ...@@ -1503,7 +1504,7 @@ namespace sw
RValue<Int2> operator=(const Int2 &rhs) const; RValue<Int2> operator=(const Int2 &rhs) const;
RValue<Int2> operator=(const Reference<Int2> &rhs) const; RValue<Int2> operator=(const Reference<Int2> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs); RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs);
...@@ -1563,7 +1564,7 @@ namespace sw ...@@ -1563,7 +1564,7 @@ namespace sw
RValue<UInt2> operator=(const UInt2 &rhs) const; RValue<UInt2> operator=(const UInt2 &rhs) const;
RValue<UInt2> operator=(const Reference<UInt2> &rhs) const; RValue<UInt2> operator=(const Reference<UInt2> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs); RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs);
...@@ -1635,7 +1636,7 @@ namespace sw ...@@ -1635,7 +1636,7 @@ namespace sw
RValue<Int4> operator=(const Int4 &rhs) const; RValue<Int4> operator=(const Int4 &rhs) const;
RValue<Int4> operator=(const Reference<Int4> &rhs) const; RValue<Int4> operator=(const Reference<Int4> &rhs) const;
static llvm::Type *getType(); static Type *getType();
private: private:
void constant(int x, int y, int z, int w); void constant(int x, int y, int z, int w);
...@@ -1715,7 +1716,7 @@ namespace sw ...@@ -1715,7 +1716,7 @@ namespace sw
RValue<UInt4> operator=(const UInt4 &rhs) const; RValue<UInt4> operator=(const UInt4 &rhs) const;
RValue<UInt4> operator=(const Reference<UInt4> &rhs) const; RValue<UInt4> operator=(const Reference<UInt4> &rhs) const;
static llvm::Type *getType(); static Type *getType();
private: private:
void constant(int x, int y, int z, int w); void constant(int x, int y, int z, int w);
...@@ -1856,7 +1857,7 @@ namespace sw ...@@ -1856,7 +1857,7 @@ namespace sw
template<int T> template<int T>
RValue<Float> operator=(const SwizzleMask1Float4<T> &rhs) const; RValue<Float> operator=(const SwizzleMask1Float4<T> &rhs) const;
static llvm::Type *getType(); static Type *getType();
}; };
RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs); RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs);
...@@ -1921,7 +1922,7 @@ namespace sw ...@@ -1921,7 +1922,7 @@ namespace sw
// template<int T> // template<int T>
// RValue<Float2> operator=(const SwizzleMask1Float4<T> &rhs); // RValue<Float2> operator=(const SwizzleMask1Float4<T> &rhs);
static llvm::Type *getType(); static Type *getType();
}; };
// RValue<Float2> operator+(RValue<Float2> lhs, RValue<Float2> rhs); // RValue<Float2> operator+(RValue<Float2> lhs, RValue<Float2> rhs);
...@@ -1991,7 +1992,7 @@ namespace sw ...@@ -1991,7 +1992,7 @@ namespace sw
template<int T> template<int T>
RValue<Float4> operator=(const SwizzleFloat4<T> &rhs); RValue<Float4> operator=(const SwizzleFloat4<T> &rhs);
static llvm::Type *getType(); static Type *getType();
union union
{ {
...@@ -2415,7 +2416,7 @@ namespace sw ...@@ -2415,7 +2416,7 @@ namespace sw
Reference<T> operator[](int index); Reference<T> operator[](int index);
Reference<T> operator[](RValue<Int> index); Reference<T> operator[](RValue<Int> index);
static llvm::Type *getType(); static Type *getType();
private: private:
const int alignment; const int alignment;
...@@ -2503,7 +2504,7 @@ namespace sw ...@@ -2503,7 +2504,7 @@ namespace sw
protected: protected:
Nucleus *core; Nucleus *core;
std::vector<llvm::Type*> arguments; std::vector<Type*> arguments;
}; };
template<typename Return> template<typename Return>
...@@ -2847,7 +2848,7 @@ namespace sw ...@@ -2847,7 +2848,7 @@ namespace sw
} }
template<class T> template<class T>
llvm::Type *Pointer<T>::getType() Type *Pointer<T>::getType()
{ {
return Nucleus::getPointerType(T::getType()); return Nucleus::getPointerType(T::getType());
} }
...@@ -2947,8 +2948,8 @@ namespace sw ...@@ -2947,8 +2948,8 @@ namespace sw
{ {
core = new Nucleus(); core = new Nucleus();
llvm::Type *types[] = {Arguments::getType()...}; Type *types[] = {Arguments::getType()...};
for(llvm::Type *type : types) for(Type *type : types)
{ {
if(type != Void::getType()) if(type != Void::getType())
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment