Implemented ALL the logical instructions
This commit is contained in:
parent
bdf538bd64
commit
aa2eaab480
2 changed files with 114 additions and 6 deletions
|
@ -258,9 +258,67 @@ class Module {
|
|||
|
||||
// Logical
|
||||
|
||||
Id OpIsNan(Id result_type, Id operand);
|
||||
|
||||
Id OpIsInf(Id result_type, Id operand);
|
||||
|
||||
Id OpLogicalEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpLogicalNotEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpLogicalOr(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpLogicalAnd(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
/// Result is true if Operand is false. Result is false if Operand is true.
|
||||
Id OpLogicalNot(Id result_type, Id operand);
|
||||
|
||||
Id OpSelect(Id result_type, Id condition, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpIEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpINotEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpUGreaterThan(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpSGreaterThan(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpUGreaterThanEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpSGreaterThanEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpULessThan(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpSLessThan(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpULessThanEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpSLessThanEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpFOrdEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpFUnordEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpFOrdNotEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpFUnordNotEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpFOrdLessThan(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpFUnordLessThan(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpFOrdGreaterThan(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpFUnordGreaterThan(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpFOrdLessThanEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpFUnordLessThanEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpFOrdGreaterThanEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
Id OpFUnordGreaterThanEqual(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
// Conversion
|
||||
|
||||
/// Bit pattern-preserving type conversion.
|
||||
|
|
|
@ -11,10 +11,60 @@
|
|||
|
||||
namespace Sirit {
|
||||
|
||||
Id Module::OpLogicalNot(Id result_type, Id operand) {
|
||||
auto op{std::make_unique<Op>(spv::Op::OpLogicalNot, bound++, result_type)};
|
||||
op->Add(operand);
|
||||
return AddCode(std::move(op));
|
||||
}
|
||||
#define DEFINE_UNARY(funcname, opcode) \
|
||||
Id Module::funcname(Id result_type, Id operand) { \
|
||||
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
|
||||
op->Add(operand); \
|
||||
return AddCode(std::move(op)); \
|
||||
}
|
||||
|
||||
} // namespace Sirit
|
||||
#define DEFINE_BINARY(funcname, opcode) \
|
||||
Id Module::funcname(Id result_type, Id operand_1, Id operand_2) { \
|
||||
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
|
||||
op->Add(operand_1); \
|
||||
op->Add(operand_2); \
|
||||
return AddCode(std::move(op)); \
|
||||
}
|
||||
|
||||
#define DEFINE_TRINARY(funcname, opcode) \
|
||||
Id Module::funcname(Id result_type, Id operand_1, Id operand_2, \
|
||||
Id operand_3) { \
|
||||
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
|
||||
op->Add(operand_1); \
|
||||
op->Add(operand_2); \
|
||||
op->Add(operand_3); \
|
||||
return AddCode(std::move(op)); \
|
||||
}
|
||||
|
||||
DEFINE_UNARY(OpIsNan, spv::Op::OpIsNan)
|
||||
DEFINE_UNARY(OpIsInf, spv::Op::OpIsInf)
|
||||
DEFINE_BINARY(OpLogicalEqual, spv::Op::OpLogicalEqual)
|
||||
DEFINE_BINARY(OpLogicalNotEqual, spv::Op::OpLogicalNotEqual)
|
||||
DEFINE_BINARY(OpLogicalOr, spv::Op::OpLogicalOr)
|
||||
DEFINE_BINARY(OpLogicalAnd, spv::Op::OpLogicalAnd)
|
||||
DEFINE_UNARY(OpLogicalNot, spv::Op::OpLogicalNot)
|
||||
DEFINE_TRINARY(OpSelect, spv::Op::OpSelect)
|
||||
DEFINE_BINARY(OpIEqual, spv::Op::OpIEqual)
|
||||
DEFINE_BINARY(OpINotEqual, spv::Op::OpINotEqual)
|
||||
DEFINE_BINARY(OpUGreaterThan, spv::Op::OpUGreaterThan)
|
||||
DEFINE_BINARY(OpSGreaterThan, spv::Op::OpSGreaterThan)
|
||||
DEFINE_BINARY(OpUGreaterThanEqual, spv::Op::OpUGreaterThanEqual)
|
||||
DEFINE_BINARY(OpSGreaterThanEqual, spv::Op::OpSGreaterThanEqual)
|
||||
DEFINE_BINARY(OpULessThan, spv::Op::OpULessThan)
|
||||
DEFINE_BINARY(OpSLessThan, spv::Op::OpSLessThan)
|
||||
DEFINE_BINARY(OpULessThanEqual, spv::Op::OpULessThanEqual)
|
||||
DEFINE_BINARY(OpSLessThanEqual, spv::Op::OpSLessThanEqual)
|
||||
DEFINE_BINARY(OpFOrdEqual, spv::Op::OpFOrdEqual)
|
||||
DEFINE_BINARY(OpFUnordEqual, spv::Op::OpFUnordEqual)
|
||||
DEFINE_BINARY(OpFOrdNotEqual, spv::Op::OpFOrdNotEqual)
|
||||
DEFINE_BINARY(OpFUnordNotEqual, spv::Op::OpFUnordNotEqual)
|
||||
DEFINE_BINARY(OpFOrdLessThan, spv::Op::OpFOrdLessThan)
|
||||
DEFINE_BINARY(OpFUnordLessThan, spv::Op::OpFUnordLessThan)
|
||||
DEFINE_BINARY(OpFOrdGreaterThan, spv::Op::OpFOrdGreaterThan)
|
||||
DEFINE_BINARY(OpFUnordGreaterThan, spv::Op::OpFUnordGreaterThan)
|
||||
DEFINE_BINARY(OpFOrdLessThanEqual, spv::Op::OpFOrdLessThanEqual)
|
||||
DEFINE_BINARY(OpFUnordLessThanEqual, spv::Op::OpFUnordLessThanEqual)
|
||||
DEFINE_BINARY(OpFOrdGreaterThanEqual, spv::Op::OpFOrdGreaterThanEqual)
|
||||
DEFINE_BINARY(OpFUnordGreaterThanEqual, spv::Op::OpFUnordGreaterThanEqual)
|
||||
|
||||
} // namespace Sirit
|
||||
|
|
Loading…
Reference in a new issue