From 13ac2327184133f5a69584ff2d69bc2cdeec1457 Mon Sep 17 00:00:00 2001 From: Nicolas Capens Date: Thu, 13 Oct 2016 14:52:12 -0400 Subject: [PATCH] Refactor constant creation. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Distinguishing between Values and Constants complicates the creation of constant vectors, and isn't necessary when using Subzero assign operations to convert between them internally. Also, construct vector constants from arrays of basic types. Bug swiftshader:17 Change-Id: I9c03655ed18d5b4bd3797a252cd7f02793205254 Reviewed-on: https://swiftshader-review.googlesource.com/7713 Reviewed-by: Nicolas Capens Tested-by: Nicolas Capens Reviewed-on: https://swiftshader-review.googlesource.com/7650 Reviewed-by: Alexis Hétu --- src/Reactor/LLVMReactor.cpp | 232 +++++++++++++----------------------- src/Reactor/Nucleus.hpp | 34 +++--- src/Reactor/Reactor.hpp | 16 +-- src/Reactor/SubzeroReactor.cpp | 79 +++++------- src/SwiftShader/SwiftShader.vcxproj | 5 - 5 files changed, 127 insertions(+), 239 deletions(-) diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp index fdc358ae3..ff00fd68b 100644 --- a/src/Reactor/LLVMReactor.cpp +++ b/src/Reactor/LLVMReactor.cpp @@ -79,7 +79,6 @@ namespace sw class Type : public llvm::Type {}; class Value : public llvm::Value {}; - class Constant : public llvm::Constant {}; class BasicBlock : public llvm::BasicBlock {}; inline Type *T(llvm::Type *t) @@ -97,11 +96,6 @@ namespace sw return reinterpret_cast&>(t); } - inline Constant *C(llvm::Constant *c) - { - return reinterpret_cast(c); - } - inline BasicBlock *B(llvm::BasicBlock *t) { return reinterpret_cast(t); @@ -433,11 +427,6 @@ namespace sw return V(::builder->CreateXor(lhs, rhs)); } - Value *Nucleus::createAssign(Constant *constant) - { - return V(constant); - } - Value *Nucleus::createNeg(Value *v) { return V(::builder->CreateNeg(v)); @@ -466,13 +455,6 @@ namespace sw return value; } - Constant *Nucleus::createStore(Constant *constant, Value *ptr, Type *type, bool isVolatile, unsigned int align) - { - assert(ptr->getType()->getContainedType(0) == type); - ::builder->Insert(new StoreInst(constant, ptr, isVolatile, align)); - return constant; - } - Value *Nucleus::createGEP(Value *ptr, Type *type, Value *index) { assert(ptr->getType()->getContainedType(0) == type); @@ -674,7 +656,7 @@ namespace sw for(int i = 0; i < size; i++) { - swizzle[i] = Nucleus::createConstantInt(select[i]); + swizzle[i] = llvm::ConstantInt::get(Type::getInt32Ty(*::context), select[i]); } llvm::Value *shuffle = llvm::ConstantVector::get(llvm::ArrayRef(swizzle, size)); @@ -737,13 +719,13 @@ namespace sw return shuffle; } - Constant *Nucleus::createConstantPointer(const void *address, Type *Ty, bool isConstant, unsigned int Align) + Value *Nucleus::createConstantPointer(const void *address, Type *Ty, bool isConstant, unsigned int Align) { const GlobalValue *existingGlobal = ::executionEngine->getGlobalValueAtAddress(const_cast(address)); // FIXME: Const if(existingGlobal) { - return (Constant*)existingGlobal; + return (Value*)existingGlobal; } llvm::GlobalValue *global = new llvm::GlobalVariable(*::module, Ty, isConstant, llvm::GlobalValue::ExternalLinkage, 0, ""); @@ -752,7 +734,7 @@ namespace sw ::executionEngine->addGlobalMapping(global, const_cast(address)); - return C(global); + return V(global); } Type *Nucleus::getPointerType(Type *ElementType) @@ -760,64 +742,89 @@ namespace sw return T(llvm::PointerType::get(ElementType, 0)); } - Constant *Nucleus::createNullValue(Type *Ty) + Value *Nucleus::createNullValue(Type *Ty) { - return C(llvm::Constant::getNullValue(Ty)); + return V(llvm::Constant::getNullValue(Ty)); } - Constant *Nucleus::createConstantInt(int64_t i) + Value *Nucleus::createConstantLong(int64_t i) { - return C(llvm::ConstantInt::get(Type::getInt64Ty(*::context), i, true)); + return V(llvm::ConstantInt::get(Type::getInt64Ty(*::context), i, true)); } - Constant *Nucleus::createConstantInt(int i) + Value *Nucleus::createConstantInt(int i) { - return C(llvm::ConstantInt::get(Type::getInt32Ty(*::context), i, true)); + return V(llvm::ConstantInt::get(Type::getInt32Ty(*::context), i, true)); } - Constant *Nucleus::createConstantInt(unsigned int i) + Value *Nucleus::createConstantInt(unsigned int i) { - return C(llvm::ConstantInt::get(Type::getInt32Ty(*::context), i, false)); + return V(llvm::ConstantInt::get(Type::getInt32Ty(*::context), i, false)); } - Constant *Nucleus::createConstantBool(bool b) + Value *Nucleus::createConstantBool(bool b) { - return C(llvm::ConstantInt::get(Type::getInt1Ty(*::context), b)); + return V(llvm::ConstantInt::get(Type::getInt1Ty(*::context), b)); } - Constant *Nucleus::createConstantByte(signed char i) + Value *Nucleus::createConstantByte(signed char i) { - return C(llvm::ConstantInt::get(Type::getInt8Ty(*::context), i, true)); + return V(llvm::ConstantInt::get(Type::getInt8Ty(*::context), i, true)); } - Constant *Nucleus::createConstantByte(unsigned char i) + Value *Nucleus::createConstantByte(unsigned char i) { - return C(llvm::ConstantInt::get(Type::getInt8Ty(*::context), i, false)); + return V(llvm::ConstantInt::get(Type::getInt8Ty(*::context), i, false)); } - Constant *Nucleus::createConstantShort(short i) + Value *Nucleus::createConstantShort(short i) { - return C(llvm::ConstantInt::get(Type::getInt16Ty(*::context), i, true)); + return V(llvm::ConstantInt::get(Type::getInt16Ty(*::context), i, true)); } - Constant *Nucleus::createConstantShort(unsigned short i) + Value *Nucleus::createConstantShort(unsigned short i) { - return C(llvm::ConstantInt::get(Type::getInt16Ty(*::context), i, false)); + return V(llvm::ConstantInt::get(Type::getInt16Ty(*::context), i, false)); } - Constant *Nucleus::createConstantFloat(float x) + Value *Nucleus::createConstantFloat(float x) { - return C(ConstantFP::get(Float::getType(), x)); + return V(llvm::ConstantFP::get(Float::getType(), x)); } - Constant *Nucleus::createNullPointer(Type *Ty) + Value *Nucleus::createNullPointer(Type *Ty) { - return C(llvm::ConstantPointerNull::get(llvm::PointerType::get(Ty, 0))); + return V(llvm::ConstantPointerNull::get(llvm::PointerType::get(Ty, 0))); + } + + Value *Nucleus::createConstantVector(const int64_t *constants, Type *type) + { + assert(llvm::isa(type)); + const int numConstants = llvm::cast(type)->getNumElements(); + assert(numConstants <= 16); + llvm::Constant *constantVector[16]; + + for(int i = 0; i < numConstants; i++) + { + constantVector[i] = llvm::ConstantInt::get(type->getContainedType(0), constants[i]); + } + + return V(llvm::ConstantVector::get(llvm::ArrayRef(constantVector, numConstants))); } - Constant *Nucleus::createConstantVector(Constant *const *Vals, unsigned NumVals) + Value *Nucleus::createConstantVector(const double *constants, Type *type) { - return C(llvm::ConstantVector::get(llvm::ArrayRef(reinterpret_cast(Vals), NumVals))); + assert(llvm::isa(type)); + const int numConstants = llvm::cast(type)->getNumElements(); + assert(numConstants <= 8); + llvm::Constant *constantVector[8]; + + for(int i = 0; i < numConstants; i++) + { + constantVector[i] = llvm::ConstantFP::get(type->getContainedType(0), constants[i]); + } + + return V(llvm::ConstantVector::get(llvm::ArrayRef(constantVector, numConstants))); } Type *Void::getType() @@ -1973,16 +1980,8 @@ namespace sw { // xyzw.parent = this; - Constant *constantVector[8]; - constantVector[0] = Nucleus::createConstantByte(x0); - constantVector[1] = Nucleus::createConstantByte(x1); - constantVector[2] = Nucleus::createConstantByte(x2); - constantVector[3] = Nucleus::createConstantByte(x3); - constantVector[4] = Nucleus::createConstantByte(x4); - constantVector[5] = Nucleus::createConstantByte(x5); - constantVector[6] = Nucleus::createConstantByte(x6); - constantVector[7] = Nucleus::createConstantByte(x7); - Value *vector = V(Nucleus::createConstantVector(constantVector, 8)); + int64_t constantVector[8] = {x0, x1, x2, x3, x4, x5, x6, x7}; + Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Byte::getType(), 8)))); storeValue(Nucleus::createBitCast(vector, getType())); } @@ -2274,16 +2273,8 @@ namespace sw { // xyzw.parent = this; - Constant *constantVector[8]; - constantVector[0] = Nucleus::createConstantByte(x0); - constantVector[1] = Nucleus::createConstantByte(x1); - constantVector[2] = Nucleus::createConstantByte(x2); - constantVector[3] = Nucleus::createConstantByte(x3); - constantVector[4] = Nucleus::createConstantByte(x4); - constantVector[5] = Nucleus::createConstantByte(x5); - constantVector[6] = Nucleus::createConstantByte(x6); - constantVector[7] = Nucleus::createConstantByte(x7); - Value *vector = V(Nucleus::createConstantVector(constantVector, 8)); + int64_t constantVector[8] = {x0, x1, x2, x3, x4, x5, x6, x7}; + Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(SByte::getType(), 8)))); storeValue(Nucleus::createBitCast(vector, getType())); } @@ -2696,12 +2687,8 @@ namespace sw { // xyzw.parent = this; - Constant *constantVector[4]; - constantVector[0] = Nucleus::createConstantShort(xyzw); - constantVector[1] = Nucleus::createConstantShort(xyzw); - constantVector[2] = Nucleus::createConstantShort(xyzw); - constantVector[3] = Nucleus::createConstantShort(xyzw); - Value *vector = V(Nucleus::createConstantVector(constantVector, 4)); + int64_t constantVector[4] = {xyzw, xyzw, xyzw, xyzw}; + Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Short::getType(), 4)))); storeValue(Nucleus::createBitCast(vector, getType())); } @@ -2710,12 +2697,8 @@ namespace sw { // xyzw.parent = this; - Constant *constantVector[4]; - constantVector[0] = Nucleus::createConstantShort(x); - constantVector[1] = Nucleus::createConstantShort(y); - constantVector[2] = Nucleus::createConstantShort(z); - constantVector[3] = Nucleus::createConstantShort(w); - Value *vector = V(Nucleus::createConstantVector(constantVector, 4)); + int64_t constantVector[4] = {x, y, z, w}; + Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Short::getType(), 4)))); storeValue(Nucleus::createBitCast(vector, getType())); } @@ -3186,12 +3169,8 @@ namespace sw { // xyzw.parent = this; - Constant *constantVector[4]; - constantVector[0] = Nucleus::createConstantShort(xyzw); - constantVector[1] = Nucleus::createConstantShort(xyzw); - constantVector[2] = Nucleus::createConstantShort(xyzw); - constantVector[3] = Nucleus::createConstantShort(xyzw); - Value *vector = V(Nucleus::createConstantVector(constantVector, 4)); + int64_t constantVector[4] = {xyzw, xyzw, xyzw, xyzw}; + Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(UShort::getType(), 4)))); storeValue(Nucleus::createBitCast(vector, getType())); } @@ -3200,12 +3179,8 @@ namespace sw { // xyzw.parent = this; - Constant *constantVector[4]; - constantVector[0] = Nucleus::createConstantShort(x); - constantVector[1] = Nucleus::createConstantShort(y); - constantVector[2] = Nucleus::createConstantShort(z); - constantVector[3] = Nucleus::createConstantShort(w); - Value *vector = V(Nucleus::createConstantVector(constantVector, 4)); + int64_t constantVector[4] = {x, y, z, w}; + Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(UShort::getType(), 4)))); storeValue(Nucleus::createBitCast(vector, getType())); } @@ -3485,17 +3460,8 @@ namespace sw { // xyzw.parent = this; - Constant *constantVector[8]; - constantVector[0] = Nucleus::createConstantShort(c0); - constantVector[1] = Nucleus::createConstantShort(c1); - constantVector[2] = Nucleus::createConstantShort(c2); - constantVector[3] = Nucleus::createConstantShort(c3); - constantVector[4] = Nucleus::createConstantShort(c4); - constantVector[5] = Nucleus::createConstantShort(c5); - constantVector[6] = Nucleus::createConstantShort(c6); - constantVector[7] = Nucleus::createConstantShort(c7); - - storeValue(Nucleus::createConstantVector(constantVector, 8)); + int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7}; + storeValue(Nucleus::createConstantVector(constantVector, getType())); } Short8::Short8(RValue rhs) @@ -3578,17 +3544,8 @@ namespace sw { // xyzw.parent = this; - Constant *constantVector[8]; - constantVector[0] = Nucleus::createConstantShort(c0); - constantVector[1] = Nucleus::createConstantShort(c1); - constantVector[2] = Nucleus::createConstantShort(c2); - constantVector[3] = Nucleus::createConstantShort(c3); - constantVector[4] = Nucleus::createConstantShort(c4); - constantVector[5] = Nucleus::createConstantShort(c5); - constantVector[6] = Nucleus::createConstantShort(c6); - constantVector[7] = Nucleus::createConstantShort(c7); - - storeValue(Nucleus::createConstantVector(constantVector, 8)); + int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7}; + storeValue(Nucleus::createConstantVector(constantVector, getType())); } UShort8::UShort8(RValue rhs) @@ -4095,7 +4052,7 @@ namespace sw RValue Long::operator=(int64_t rhs) const { - return RValue(storeValue(Nucleus::createConstantInt(rhs))); + return RValue(storeValue(Nucleus::createConstantLong(rhs))); } RValue Long::operator=(RValue rhs) const @@ -4563,10 +4520,8 @@ namespace sw { // xy.parent = this; - Constant *constantVector[2]; - constantVector[0] = Nucleus::createConstantInt(x); - constantVector[1] = Nucleus::createConstantInt(y); - Value *vector = V(Nucleus::createConstantVector(constantVector, 2)); + int64_t constantVector[2] = {x, y}; + Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Int::getType(), 2)))); storeValue(Nucleus::createBitCast(vector, getType())); } @@ -4897,10 +4852,8 @@ namespace sw { // xy.parent = this; - Constant *constantVector[2]; - constantVector[0] = Nucleus::createConstantInt(x); - constantVector[1] = Nucleus::createConstantInt(y); - Value *vector = V(Nucleus::createConstantVector(constantVector, 2)); + int64_t constantVector[2] = {x, y}; + Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(UInt::getType(), 2)))); storeValue(Nucleus::createBitCast(vector, getType())); } @@ -5291,13 +5244,8 @@ namespace sw { // xyzw.parent = this; - Constant *constantVector[4]; - constantVector[0] = Nucleus::createConstantInt(x); - constantVector[1] = Nucleus::createConstantInt(y); - constantVector[2] = Nucleus::createConstantInt(z); - constantVector[3] = Nucleus::createConstantInt(w); - - storeValue(Nucleus::createConstantVector(constantVector, 4)); + int64_t constantVector[4] = {x, y, z, w}; + storeValue(Nucleus::createConstantVector(constantVector, getType())); } Int4::Int4(RValue rhs) @@ -5686,13 +5634,8 @@ namespace sw { // xyzw.parent = this; - Constant *constantVector[4]; - constantVector[0] = Nucleus::createConstantInt(x); - constantVector[1] = Nucleus::createConstantInt(y); - constantVector[2] = Nucleus::createConstantInt(z); - constantVector[3] = Nucleus::createConstantInt(w); - - storeValue(Nucleus::createConstantVector(constantVector, 4)); + int64_t constantVector[4] = {x, y, z, w}; + storeValue(Nucleus::createConstantVector(constantVector, getType())); } UInt4::UInt4(RValue rhs) @@ -6361,13 +6304,8 @@ namespace sw { xyzw.parent = this; - Constant *constantVector[4]; - constantVector[0] = Nucleus::createConstantFloat(x); - constantVector[1] = Nucleus::createConstantFloat(y); - constantVector[2] = Nucleus::createConstantFloat(z); - constantVector[3] = Nucleus::createConstantFloat(w); - - storeValue(Nucleus::createConstantVector(constantVector, 4)); + double constantVector[4] = {x, y, z, w}; + storeValue(Nucleus::createConstantVector(constantVector, getType())); } Float4::Float4(RValue rhs) @@ -6526,14 +6464,8 @@ namespace sw RValue Abs(RValue x) { Value *vector = Nucleus::createBitCast(x.value, Int4::getType()); - - Constant *constantVector[4]; - constantVector[0] = Nucleus::createConstantInt(0x7FFFFFFF); - constantVector[1] = Nucleus::createConstantInt(0x7FFFFFFF); - constantVector[2] = Nucleus::createConstantInt(0x7FFFFFFF); - constantVector[3] = Nucleus::createConstantInt(0x7FFFFFFF); - - Value *result = Nucleus::createAnd(vector, V(Nucleus::createConstantVector(constantVector, 4))); + int64_t constantVector[4] = {0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF}; + Value *result = Nucleus::createAnd(vector, V(Nucleus::createConstantVector(constantVector, Int4::getType()))); return RValue(Nucleus::createBitCast(result, Float4::getType())); } diff --git a/src/Reactor/Nucleus.hpp b/src/Reactor/Nucleus.hpp index ed265e67b..51c041b6c 100644 --- a/src/Reactor/Nucleus.hpp +++ b/src/Reactor/Nucleus.hpp @@ -23,7 +23,6 @@ namespace sw { class Type; class Value; - class Constant; class BasicBlock; class Routine; @@ -90,7 +89,6 @@ namespace sw static Value *createXor(Value *lhs, Value *rhs); // Unary operators - static Value *createAssign(Constant *c); static Value *createNeg(Value *V); static Value *createFNeg(Value *V); static Value *createNot(Value *V); @@ -98,7 +96,6 @@ namespace sw // Memory instructions static Value *createLoad(Value *ptr, Type *type, bool isVolatile = false, unsigned int align = 0); static Value *createStore(Value *value, Value *ptr, Type *type, bool isVolatile = false, unsigned int align = 0); - static Constant *createStore(Constant *constant, Value *ptr, Type *type, bool isVolatile = false, unsigned int align = 0); static Value *createGEP(Value *ptr, Type *type, Value *index); // Atomic instructions @@ -154,21 +151,22 @@ namespace sw static void createUnreachable(); // Constant values - static Constant *createNullValue(Type *Ty); - static Constant *createConstantInt(int64_t i); - static Constant *createConstantInt(int i); - static Constant *createConstantInt(unsigned int i); - static Constant *createConstantBool(bool b); - static Constant *createConstantByte(signed char i); - static Constant *createConstantByte(unsigned char i); - static Constant *createConstantShort(short i); - static Constant *createConstantShort(unsigned short i); - static Constant *createConstantFloat(float x); - static Constant *createNullPointer(Type *Ty); - static Constant *createConstantVector(Constant *const *Vals, unsigned NumVals); - static Constant *createConstantPointer(const void *external, Type *Ty, bool isConstant, unsigned int Align); - - static Type *getPointerType(Type *ElementType); + static Value *createNullValue(Type *type); + static Value *createConstantLong(int64_t i); + static Value *createConstantInt(int i); + static Value *createConstantInt(unsigned int i); + static Value *createConstantBool(bool b); + static Value *createConstantByte(signed char i); + static Value *createConstantByte(unsigned char i); + static Value *createConstantShort(short i); + static Value *createConstantShort(unsigned short i); + static Value *createConstantFloat(float x); + static Value *createNullPointer(Type *type); + static Value *createConstantVector(const int64_t *constants, Type *type); + static Value *createConstantVector(const double *constants, Type *type); + static Value *createConstantPointer(const void *external, Type *type, bool isConstant, unsigned int align); + + static Type *getPointerType(Type *elementType); private: void optimize(); diff --git a/src/Reactor/Reactor.hpp b/src/Reactor/Reactor.hpp index cbef8550d..79433f576 100644 --- a/src/Reactor/Reactor.hpp +++ b/src/Reactor/Reactor.hpp @@ -83,7 +83,6 @@ namespace sw Value *loadValue(unsigned int alignment = 0) const; Value *storeValue(Value *value, unsigned int alignment = 0) const; - Constant *storeValue(Constant *constant, unsigned int alignment = 0) const; Value *getAddress(Value *index) const; protected: @@ -160,7 +159,6 @@ namespace sw { public: explicit RValue(Value *rvalue); - explicit RValue(Constant *constant); RValue(const T &lvalue); RValue(typename IntLiteral::type i); @@ -2382,12 +2380,6 @@ namespace sw } template - Constant *LValue::storeValue(Constant *constant, unsigned int alignment) const - { - return Nucleus::createStore(constant, address, T::getType(), false, alignment); - } - - template Value *LValue::getAddress(Value *index) const { return Nucleus::createGEP(address, T::getType(), index); @@ -2452,12 +2444,6 @@ namespace sw } template - RValue::RValue(Constant *constant) - { - value = Nucleus::createAssign(constant); - } - - template RValue::RValue(const T &lvalue) { value = lvalue.loadValue(); @@ -2644,7 +2630,7 @@ namespace sw template Pointer::Pointer(const void *external) : alignment((intptr_t)external & 0x0000000F ? 1 : 16) { - Constant *globalPointer = Nucleus::createConstantPointer(external, T::getType(), false, alignment); + Value *globalPointer = Nucleus::createConstantPointer(external, T::getType(), false, alignment); LValue>::storeValue(globalPointer); } diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp index ee3b323f0..df16d7992 100644 --- a/src/Reactor/SubzeroReactor.cpp +++ b/src/Reactor/SubzeroReactor.cpp @@ -68,7 +68,6 @@ namespace sw }; class Value : public Ice::Variable {}; - class Constant : public Ice::Constant {}; class BasicBlock : public Ice::CfgNode {}; Ice::Type T(Type *t) @@ -92,11 +91,6 @@ namespace sw return reinterpret_cast(v); } - Constant *C(Ice::Constant *c) - { - return reinterpret_cast(c); - } - BasicBlock *B(Ice::CfgNode *b) { return reinterpret_cast(b); @@ -456,7 +450,7 @@ namespace sw return createArithmetic(Ice::InstArithmetic::Xor, lhs, rhs); } - Value *Nucleus::createAssign(Constant *constant) + static Value *createAssign(Ice::Constant *constant) { Ice::Variable *value = ::function->makeVariable(constant->getType()); auto assign = Ice::InstAssign::create(::function, value, constant); @@ -571,20 +565,13 @@ namespace sw return value; } - Constant *Nucleus::createStore(Constant *constant, Value *ptr, Type *type, bool isVolatile, unsigned int align) - { - auto store = Ice::InstStore::create(::function, constant, ptr, align); - ::basicBlock->appendInst(store); - return constant; - } - Value *Nucleus::createGEP(Value *ptr, Type *type, Value *index) { assert(index->getType() == Ice::IceType_i32); if(!Ice::isByteSizedType(T(type))) { - index = createMul(index, createAssign(createConstantInt((int)Ice::typeWidthInBytes(T(type))))); + index = createMul(index, createConstantInt((int)Ice::typeWidthInBytes(T(type)))); } if(sizeof(void*) == 8) @@ -864,7 +851,7 @@ namespace sw assert(false && "UNIMPLEMENTED"); return nullptr; } - Constant *Nucleus::createConstantPointer(const void *address, Type *Ty, bool isConstant, unsigned int Align) + Value *Nucleus::createConstantPointer(const void *address, Type *Ty, bool isConstant, unsigned int Align) { assert(false && "UNIMPLEMENTED"); return nullptr; } @@ -881,62 +868,67 @@ namespace sw } } - Constant *Nucleus::createNullValue(Type *Ty) + Value *Nucleus::createNullValue(Type *Ty) { assert(false && "UNIMPLEMENTED"); return nullptr; } - Constant *Nucleus::createConstantInt(int64_t i) + Value *Nucleus::createConstantLong(int64_t i) { assert(false && "UNIMPLEMENTED"); return nullptr; } - Constant *Nucleus::createConstantInt(int i) + Value *Nucleus::createConstantInt(int i) { - return C(::context->getConstantInt32(i)); + return createAssign(::context->getConstantInt32(i)); } - Constant *Nucleus::createConstantInt(unsigned int i) + Value *Nucleus::createConstantInt(unsigned int i) { assert(false && "UNIMPLEMENTED"); return nullptr; } - Constant *Nucleus::createConstantBool(bool b) + Value *Nucleus::createConstantBool(bool b) { assert(false && "UNIMPLEMENTED"); return nullptr; } - Constant *Nucleus::createConstantByte(signed char i) + Value *Nucleus::createConstantByte(signed char i) { assert(false && "UNIMPLEMENTED"); return nullptr; } - Constant *Nucleus::createConstantByte(unsigned char i) + Value *Nucleus::createConstantByte(unsigned char i) { assert(false && "UNIMPLEMENTED"); return nullptr; } - Constant *Nucleus::createConstantShort(short i) + Value *Nucleus::createConstantShort(short i) { assert(false && "UNIMPLEMENTED"); return nullptr; } - Constant *Nucleus::createConstantShort(unsigned short i) + Value *Nucleus::createConstantShort(unsigned short i) { assert(false && "UNIMPLEMENTED"); return nullptr; } - Constant *Nucleus::createConstantFloat(float x) + Value *Nucleus::createConstantFloat(float x) { assert(false && "UNIMPLEMENTED"); return nullptr; } - Constant *Nucleus::createNullPointer(Type *Ty) + Value *Nucleus::createNullPointer(Type *Ty) { assert(false && "UNIMPLEMENTED"); return nullptr; } - Constant *Nucleus::createConstantVector(Constant *const *Vals, unsigned NumVals) + Value *Nucleus::createConstantVector(const int64_t *constants, Type *type) + { + assert(false && "UNIMPLEMENTED"); return nullptr; + } + + Value *Nucleus::createConstantVector(const double *constants, Type *type) { assert(false && "UNIMPLEMENTED"); return nullptr; } @@ -3697,7 +3689,7 @@ namespace sw RValue Long::operator=(int64_t rhs) const { - return RValue(storeValue(Nucleus::createConstantInt(rhs))); + return RValue(storeValue(Nucleus::createConstantLong(rhs))); } RValue Long::operator=(RValue rhs) const @@ -4593,13 +4585,8 @@ namespace sw { // xyzw.parent = this; - Constant *constantVector[4]; - constantVector[0] = Nucleus::createConstantInt(x); - constantVector[1] = Nucleus::createConstantInt(y); - constantVector[2] = Nucleus::createConstantInt(z); - constantVector[3] = Nucleus::createConstantInt(w); - - storeValue(Nucleus::createConstantVector(constantVector, 4)); + int64_t constantVector[4] = {x, y, z, w}; + storeValue(Nucleus::createConstantVector(constantVector, Int4::getType())); } Int4::Int4(RValue rhs) @@ -4933,13 +4920,8 @@ namespace sw { // xyzw.parent = this; - Constant *constantVector[4]; - constantVector[0] = Nucleus::createConstantInt(x); - constantVector[1] = Nucleus::createConstantInt(y); - constantVector[2] = Nucleus::createConstantInt(z); - constantVector[3] = Nucleus::createConstantInt(w); - - storeValue(Nucleus::createConstantVector(constantVector, 4)); + int64_t constantVector[4] = {x, y, z, w}; + storeValue(Nucleus::createConstantVector(constantVector, UInt4::getType())); } UInt4::UInt4(RValue rhs) @@ -5480,13 +5462,8 @@ namespace sw { xyzw.parent = this; - Constant *constantVector[4]; - constantVector[0] = Nucleus::createConstantFloat(x); - constantVector[1] = Nucleus::createConstantFloat(y); - constantVector[2] = Nucleus::createConstantFloat(z); - constantVector[3] = Nucleus::createConstantFloat(w); - - storeValue(Nucleus::createConstantVector(constantVector, 4)); + double constantVector[4] = {x, y, z, w}; + storeValue(Nucleus::createConstantVector(constantVector, Float4::getType())); } Float4::Float4(RValue rhs) diff --git a/src/SwiftShader/SwiftShader.vcxproj b/src/SwiftShader/SwiftShader.vcxproj index d76c155ae..30f26cf49 100644 --- a/src/SwiftShader/SwiftShader.vcxproj +++ b/src/SwiftShader/SwiftShader.vcxproj @@ -447,11 +447,6 @@ {28fd076d-10b5-4bd8-a4cf-f44c7002a803} - true - true - false - true - true -- 2.11.0