diff options
Diffstat (limited to 'backend/src/ir/instruction.cpp')
-rw-r--r-- | backend/src/ir/instruction.cpp | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/backend/src/ir/instruction.cpp b/backend/src/ir/instruction.cpp index 4b87d46e..5fc1535c 100644 --- a/backend/src/ir/instruction.cpp +++ b/backend/src/ir/instruction.cpp @@ -314,6 +314,7 @@ namespace ir { AtomicInstruction(AtomicOps atomicOp, Register dst, AddressSpace addrSpace, + BTI bti, Tuple src) { this->opcode = OP_ATOMIC; @@ -321,6 +322,7 @@ namespace ir { this->dst[0] = dst; this->src = src; this->addrSpace = addrSpace; + this->bti = bti; srcNum = 2; if((atomicOp == ATOMIC_OP_INC) || (atomicOp == ATOMIC_OP_DEC)) @@ -329,12 +331,14 @@ namespace ir { srcNum = 3; } INLINE AddressSpace getAddressSpace(void) const { return this->addrSpace; } + INLINE BTI getBTI(void) const { return bti; } INLINE AtomicOps getAtomicOpcode(void) const { return this->atomicOp; } INLINE bool wellFormed(const Function &fn, std::string &whyNot) const; INLINE void out(std::ostream &out, const Function &fn) const; Register dst[1]; Tuple src; AddressSpace addrSpace; //!< Address space + BTI bti; //!< bti uint8_t srcNum:2; //!<Source Number AtomicOps atomicOp:6; //!<Source Number }; @@ -400,7 +404,8 @@ namespace ir { Register offset, AddressSpace addrSpace, uint32_t valueNum, - bool dwAligned) + bool dwAligned, + BTI bti) { GBE_ASSERT(valueNum < 128); this->opcode = OP_LOAD; @@ -410,6 +415,7 @@ namespace ir { this->addrSpace = addrSpace; this->valueNum = valueNum; this->dwAligned = dwAligned ? 1 : 0; + this->bti = bti; } INLINE Register getDst(const Function &fn, uint32_t ID) const { GBE_ASSERTM(ID < valueNum, "Out-of-bound source register"); @@ -423,6 +429,7 @@ namespace ir { INLINE Type getValueType(void) const { return type; } INLINE uint32_t getValueNum(void) const { return valueNum; } INLINE AddressSpace getAddressSpace(void) const { return addrSpace; } + INLINE BTI getBTI(void) const { return bti; } INLINE bool wellFormed(const Function &fn, std::string &why) const; INLINE void out(std::ostream &out, const Function &fn) const; INLINE bool isAligned(void) const { return !!dwAligned; } @@ -431,6 +438,7 @@ namespace ir { Register offset; //!< Alias to make it similar to store Tuple values; //!< Values to load AddressSpace addrSpace; //!< Where to load + BTI bti; uint8_t valueNum:7; //!< Number of values to load uint8_t dwAligned:1; //!< DWORD aligned is what matters with GEN }; @@ -444,7 +452,8 @@ namespace ir { Register offset, AddressSpace addrSpace, uint32_t valueNum, - bool dwAligned) + bool dwAligned, + BTI bti) { GBE_ASSERT(valueNum < 255); this->opcode = OP_STORE; @@ -454,6 +463,7 @@ namespace ir { this->addrSpace = addrSpace; this->valueNum = valueNum; this->dwAligned = dwAligned ? 1 : 0; + this->bti = bti; } INLINE Register getSrc(const Function &fn, uint32_t ID) const { GBE_ASSERTM(ID < valueNum + 1u, "Out-of-bound source register for store"); @@ -473,6 +483,7 @@ namespace ir { INLINE uint32_t getValueNum(void) const { return valueNum; } INLINE Type getValueType(void) const { return type; } INLINE AddressSpace getAddressSpace(void) const { return addrSpace; } + INLINE BTI getBTI(void) const { return bti; } INLINE bool wellFormed(const Function &fn, std::string &why) const; INLINE void out(std::ostream &out, const Function &fn) const; INLINE bool isAligned(void) const { return !!dwAligned; } @@ -480,6 +491,7 @@ namespace ir { Register offset; //!< First source is the offset where to store Tuple values; //!< Values to store AddressSpace addrSpace; //!< Where to store + BTI bti; //!< Which btis need access uint8_t valueNum:7; //!< Number of values to store uint8_t dwAligned:1; //!< DWORD aligned is what matters with GEN Register dst[0]; //!< No destination @@ -1069,6 +1081,9 @@ namespace ir { out << " {" << "%" << this->getSrc(fn, 0) << "}"; for (uint32_t i = 1; i < srcNum; ++i) out << " %" << this->getSrc(fn, i); + out << " bti"; + for (uint32_t i = 0; i < bti.count; ++i) + out << ": " << (int)bti.bti[i]; } @@ -1103,6 +1118,9 @@ namespace ir { out << "%" << this->getDst(fn, i) << (i != (valueNum-1u) ? " " : ""); out << "}"; out << " %" << this->getSrc(fn, 0); + out << " bti"; + for (uint32_t i = 0; i < bti.count; ++i) + out << ": " << (int)bti.bti[i]; } INLINE void StoreInstruction::out(std::ostream &out, const Function &fn) const { @@ -1112,6 +1130,9 @@ namespace ir { for (uint32_t i = 0; i < valueNum; ++i) out << "%" << this->getSrc(fn, i+1) << (i != (valueNum-1u) ? " " : ""); out << "}"; + out << " bti"; + for (uint32_t i = 0; i < bti.count; ++i) + out << ": " << (int)bti.bti[i]; } INLINE void LabelInstruction::out(std::ostream &out, const Function &fn) const { @@ -1183,7 +1204,7 @@ namespace ir { return HelperIntrospection<CLASS, RefClass>::value == 1; #define START_INTROSPECTION(CLASS) \ - static_assert(sizeof(internal::CLASS) == sizeof(uint64_t), \ + static_assert(sizeof(internal::CLASS) == (sizeof(uint64_t)*2), \ "Bad instruction size"); \ static_assert(offsetof(internal::CLASS, opcode) == 0, \ "Bad opcode offset"); \ @@ -1427,14 +1448,17 @@ DECL_MEM_FN(BitCastInstruction, Type, getDstType(void), getDstType()) DECL_MEM_FN(ConvertInstruction, Type, getSrcType(void), getSrcType()) DECL_MEM_FN(ConvertInstruction, Type, getDstType(void), getDstType()) DECL_MEM_FN(AtomicInstruction, AddressSpace, getAddressSpace(void), getAddressSpace()) +DECL_MEM_FN(AtomicInstruction, BTI, getBTI(void), getBTI()) DECL_MEM_FN(AtomicInstruction, AtomicOps, getAtomicOpcode(void), getAtomicOpcode()) DECL_MEM_FN(StoreInstruction, Type, getValueType(void), getValueType()) DECL_MEM_FN(StoreInstruction, uint32_t, getValueNum(void), getValueNum()) DECL_MEM_FN(StoreInstruction, AddressSpace, getAddressSpace(void), getAddressSpace()) +DECL_MEM_FN(StoreInstruction, BTI, getBTI(void), getBTI()) DECL_MEM_FN(StoreInstruction, bool, isAligned(void), isAligned()) DECL_MEM_FN(LoadInstruction, Type, getValueType(void), getValueType()) DECL_MEM_FN(LoadInstruction, uint32_t, getValueNum(void), getValueNum()) DECL_MEM_FN(LoadInstruction, AddressSpace, getAddressSpace(void), getAddressSpace()) +DECL_MEM_FN(LoadInstruction, BTI, getBTI(void), getBTI()) DECL_MEM_FN(LoadInstruction, bool, isAligned(void), isAligned()) DECL_MEM_FN(LoadImmInstruction, Type, getType(void), getType()) DECL_MEM_FN(LabelInstruction, LabelIndex, getLabelIndex(void), getLabelIndex()) @@ -1578,8 +1602,8 @@ DECL_MEM_FN(GetImageInfoInstruction, const uint8_t, getImageIndex(void), getImag } // For all unary functions with given opcode - Instruction ATOMIC(AtomicOps atomicOp, Register dst, AddressSpace space, Tuple src) { - return internal::AtomicInstruction(atomicOp, dst, space, src).convert(); + Instruction ATOMIC(AtomicOps atomicOp, Register dst, AddressSpace space, BTI bti, Tuple src) { + return internal::AtomicInstruction(atomicOp, dst, space, bti, src).convert(); } // BRA @@ -1607,9 +1631,10 @@ DECL_MEM_FN(GetImageInfoInstruction, const uint8_t, getImageIndex(void), getImag Register offset, \ AddressSpace space, \ uint32_t valueNum, \ - bool dwAligned) \ + bool dwAligned, \ + BTI bti) \ { \ - return internal::CLASS(type,tuple,offset,space,valueNum,dwAligned).convert(); \ + return internal::CLASS(type,tuple,offset,space,valueNum,dwAligned,bti).convert(); \ } DECL_EMIT_FUNCTION(LOAD, LoadInstruction) |