diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-01-30 16:28:50 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-30 16:28:50 -0500 |
| commit | 5942ff81d9a63ee1e37ba81172ea579646be774e (patch) | |
| tree | 2a4cdb5851348f11a8fcde1605e81c29c1227727 /source/slang/slang-emit-c-like.cpp | |
| parent | 415409fc10cfd0d6b2eb805df8f37bdabc4f2405 (diff) | |
Support for 64 bit integer types (#1191)
* * For integer literals add postfix, and use unsigned/signed output appropriately
* Extend GLSL extension handling by type, and for adding 64 bit int extensions
* Added tests for int/uint64 types
* Add explicit Int/UInt64 emit functions to avoid ambiguity.
Diffstat (limited to 'source/slang/slang-emit-c-like.cpp')
| -rw-r--r-- | source/slang/slang-emit-c-like.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index 48ca6009b..c2bfad0a7 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -743,8 +743,51 @@ void CLikeSourceEmitter::emitSimpleValueImpl(IRInst* inst) switch(inst->op) { case kIROp_IntLit: - m_writer->emit(((IRConstant*) inst)->value.intVal); + { + auto litInst = static_cast<IRConstant*>(inst); + + IRBasicType* type = as<IRBasicType>(inst->getDataType()); + if (type) + { + switch (type->getBaseType()) + { + default: + case BaseType::Int8: + case BaseType::Int16: + case BaseType::Int: + { + m_writer->emit(litInst->value.intVal); + break; + } + case BaseType::UInt8: + case BaseType::UInt16: + case BaseType::UInt: + { + m_writer->emit(UInt(litInst->value.intVal)); + break; + } + case BaseType::Int64: + { + m_writer->emitInt64(int64_t(litInst->value.intVal)); + m_writer->emit("ll"); + break; + } + case BaseType::UInt64: + { + SLANG_COMPILE_TIME_ASSERT(sizeof(litInst->value.intVal) >= sizeof(uint64_t)); + m_writer->emitUInt64(uint64_t(litInst->value.intVal)); + m_writer->emit("ull"); + break; + } + } + } + else + { + // If no type... just output what we have + m_writer->emit(litInst->value.intVal); + } break; + } case kIROp_FloatLit: m_writer->emit(((IRConstant*) inst)->value.floatVal); |
