Merge pull request #6 from FernandoS27/conversion

Implement main conversion instructions
This commit is contained in:
ReinUsesLisp 2018-11-12 21:54:36 -03:00 committed by GitHub
commit 7c15e838c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 6 deletions

View File

@ -321,6 +321,22 @@ class Module {
// Conversion
Id OpConvertFToU(Id result_type, Id operand);
Id OpConvertFToS(Id result_type, Id operand);
Id OpConvertSToF(Id result_type, Id operand);
Id OpConvertUToF(Id result_type, Id operand);
Id OpUConvert(Id result_type, Id operand);
Id OpSConvert(Id result_type, Id operand);
Id OpFConvert(Id result_type, Id operand);
Id OpQuantizeToF16(Id result_type, Id operand);
/// Bit pattern-preserving type conversion.
Id OpBitcast(Id result_type, Id operand);

View File

@ -11,10 +11,20 @@
namespace Sirit {
Id Module::OpBitcast(Id result_type, Id operand) {
auto op{std::make_unique<Op>(spv::Op::OpBitcast, bound++, result_type)};
op->Add(operand);
return AddCode(std::move(op));
}
#define DEFINE_UNARY(opcode) \
Id Module::opcode(Id result_type, Id operand) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(operand); \
return AddCode(std::move(op)); \
}
DEFINE_UNARY(OpConvertFToU)
DEFINE_UNARY(OpConvertFToS)
DEFINE_UNARY(OpConvertSToF)
DEFINE_UNARY(OpConvertUToF)
DEFINE_UNARY(OpUConvert)
DEFINE_UNARY(OpSConvert)
DEFINE_UNARY(OpFConvert)
DEFINE_UNARY(OpQuantizeToF16)
DEFINE_UNARY(OpBitcast)
} // namespace Sirit