diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2021-02-16 11:48:21 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-16 11:48:21 -0800 |
| commit | e474c4e3aadc22a1b9f9b006104409f10936244f (patch) | |
| tree | b5f9567d3795fd2ea77d6c0478a58a569ea8eda9 /source/slang/slang-emit-cuda.cpp | |
| parent | 5777545ab7f82b91fde8779e7375628551add955 (diff) | |
Add an accessor for IRInst opcode (#1707)
* Add an accessor for IRInst opcode
This main changing is renaming `IRInst::op` over to `IRInst::m_op` and then adds an accessor `IRInst::getOp()` to read it. The rest of the changes are just changing use sites to `getOp` (or to `m_op` in the limited cases where we write to it).
This work is in anticipation of a future change that might need to store an extra bit in the same field as the opcode. It seemed better to do this massive refactoring as a separate PR.
* fixup
Diffstat (limited to 'source/slang/slang-emit-cuda.cpp')
| -rw-r--r-- | source/slang/slang-emit-cuda.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/source/slang/slang-emit-cuda.cpp b/source/slang/slang-emit-cuda.cpp index 5b29c9e81..2f5a9917d 100644 --- a/source/slang/slang-emit-cuda.cpp +++ b/source/slang/slang-emit-cuda.cpp @@ -123,7 +123,7 @@ SlangResult CUDASourceEmitter::calcScalarFuncName(HLSLIntrinsic::Op op, IRBasicT { case Op::FRem: { - if (type->op == kIROp_FloatType || type->op == kIROp_DoubleType) + if (type->getOp() == kIROp_FloatType || type->getOp() == kIROp_DoubleType) { funcName = HLSLIntrinsic::getInfo(op).funcName; } @@ -135,7 +135,7 @@ SlangResult CUDASourceEmitter::calcScalarFuncName(HLSLIntrinsic::Op op, IRBasicT if (funcName.getLength()) { outBuilder << funcName; - if (type->op == kIROp_FloatType) + if (type->getOp() == kIROp_FloatType) { outBuilder << "f"; } @@ -158,7 +158,7 @@ SlangResult CUDASourceEmitter::calcTypeName(IRType* type, CodeGenTarget target, // We allow C source, because if we need a name SLANG_ASSERT(target == CodeGenTarget::CUDASource); - switch (type->op) + switch (type->getOp()) { case kIROp_HalfType: { @@ -170,7 +170,7 @@ SlangResult CUDASourceEmitter::calcTypeName(IRType* type, CodeGenTarget target, { auto vecType = static_cast<IRVectorType*>(type); auto vecCount = int(getIntVal(vecType->getElementCount())); - const IROp elemType = vecType->getElementType()->op; + const IROp elemType = vecType->getElementType()->getOp(); UnownedStringSlice prefix = getVectorPrefix(elemType); if (prefix.getLength() <= 0) @@ -206,28 +206,28 @@ SlangResult CUDASourceEmitter::calcTypeName(IRType* type, CodeGenTarget target, #endif default: { - if (isNominalOp(type->op)) + if (isNominalOp(type->getOp())) { out << getName(type); return SLANG_OK; } - if (IRBasicType::isaImpl(type->op)) + if (IRBasicType::isaImpl(type->getOp())) { - out << getBuiltinTypeName(type->op); + out << getBuiltinTypeName(type->getOp()); return SLANG_OK; } if (auto texType = as<IRTextureTypeBase>(type)) { // We don't support TextureSampler, so ignore that - if (texType->op != kIROp_TextureSamplerType) + if (texType->getOp() != kIROp_TextureSamplerType) { return _calcCUDATextureTypeName(texType, out); } } - switch (type->op) + switch (type->getOp()) { case kIROp_SamplerStateType: out << "SamplerState"; return SLANG_OK; case kIROp_SamplerComparisonStateType: out << "SamplerComparisonState"; return SLANG_OK; @@ -393,12 +393,12 @@ static bool _areEquivalent(IRType* a, IRType* b) { return true; } - if (a->op != b->op) + if (a->getOp() != b->getOp()) { return false; } - switch (a->op) + switch (a->getOp()) { case kIROp_VectorType: { @@ -426,7 +426,7 @@ void CUDASourceEmitter::_emitInitializerListValue(IRType* dstType, IRInst* value { // When constructing a matrix or vector from a single value this is handled by the default path - switch (value->op) + switch (value->getOp()) { case kIROp_Construct: case kIROp_MakeMatrix: @@ -521,7 +521,7 @@ void CUDASourceEmitter::_emitInitializerList(IRType* elementType, IRUse* operand bool CUDASourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOuterPrec) { - switch(inst->op) + switch(inst->getOp()) { case kIROp_Construct: { @@ -529,7 +529,7 @@ bool CUDASourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu // On CUDA some of the built in types can't be used as constructors directly IRType* type = inst->getDataType(); - if (auto basicType = as<IRBasicType>(type) && !_isSingleNameBasicType(type->op)) + if (auto basicType = as<IRBasicType>(type) && !_isSingleNameBasicType(type->getOp())) { m_writer->emit("("); emitType(inst->getDataType()); @@ -615,7 +615,7 @@ void CUDASourceEmitter::emitLayoutDirectivesImpl(TargetRequest* targetReq) void CUDASourceEmitter::emitVectorTypeNameImpl(IRType* elementType, IRIntegerValue elementCount) { - m_writer->emit(getVectorPrefix(elementType->op)); + m_writer->emit(getVectorPrefix(elementType->getOp())); m_writer->emit(elementCount); } |
