Commit 4d503058 by Chris Forbes

Add support for conversion instructions

- OpSConvert, OpUConvert, OpFConvert have no valid use, as we only have one value width (32 bits) and these instructions perform width conversions only. - OpConvertFToU, OpConvertFToS, OpConvertUToF, OpConvertSToF implemented - OpBitcast implemented. Note that the spec looks scary wrt pointer types in OpBitcast, but 2.16.1 Universal Validation Rules disallows this use in the Logical addressing model. Bug: b/126952020 Change-Id: I6c1c95d5ad4e19177e40ead7713bf63ffe16c679 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/26010Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 2b287cc1
...@@ -206,6 +206,12 @@ namespace sw ...@@ -206,6 +206,12 @@ namespace sw
UNIMPLEMENTED("These instructions should have already been lowered."); UNIMPLEMENTED("These instructions should have already been lowered.");
break; break;
case spv::OpFConvert:
case spv::OpSConvert:
case spv::OpUConvert:
UNIMPLEMENTED("No valid uses for Op*Convert until we support multiple bit widths");
break;
case spv::OpLoad: case spv::OpLoad:
case spv::OpAccessChain: case spv::OpAccessChain:
case spv::OpCompositeConstruct: case spv::OpCompositeConstruct:
...@@ -236,6 +242,11 @@ namespace sw ...@@ -236,6 +242,11 @@ namespace sw
case spv::OpUMulExtended: case spv::OpUMulExtended:
case spv::OpSMulExtended: case spv::OpSMulExtended:
case spv::OpDot: case spv::OpDot:
case spv::OpConvertFToU:
case spv::OpConvertFToS:
case spv::OpConvertSToF:
case spv::OpConvertUToF:
case spv::OpBitcast:
// Instructions that yield an intermediate value // Instructions that yield an intermediate value
{ {
TypeID typeId = insn.word(1); TypeID typeId = insn.word(1);
...@@ -890,6 +901,11 @@ namespace sw ...@@ -890,6 +901,11 @@ namespace sw
case spv::OpSNegate: case spv::OpSNegate:
case spv::OpFNegate: case spv::OpFNegate:
case spv::OpLogicalNot: case spv::OpLogicalNot:
case spv::OpConvertFToU:
case spv::OpConvertFToS:
case spv::OpConvertSToF:
case spv::OpConvertUToF:
case spv::OpBitcast:
EmitUnaryOp(insn, routine); EmitUnaryOp(insn, routine);
break; break;
...@@ -1199,6 +1215,21 @@ namespace sw ...@@ -1199,6 +1215,21 @@ namespace sw
case spv::OpFNegate: case spv::OpFNegate:
dst.emplace(i, -val); dst.emplace(i, -val);
break; break;
case spv::OpConvertFToU:
dst.emplace(i, As<SIMD::Float>(SIMD::UInt(val)));
break;
case spv::OpConvertFToS:
dst.emplace(i, As<SIMD::Float>(SIMD::Int(val)));
break;
case spv::OpConvertSToF:
dst.emplace(i, SIMD::Float(As<SIMD::Int>(val)));
break;
case spv::OpConvertUToF:
dst.emplace(i, SIMD::Float(As<SIMD::UInt>(val)));
break;
case spv::OpBitcast:
dst.emplace(i, val);
break;
default: default:
UNIMPLEMENTED("Unhandled unary operator %s", OpcodeName(insn.opcode()).c_str()); UNIMPLEMENTED("Unhandled unary operator %s", OpcodeName(insn.opcode()).c_str());
} }
......
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