diff options
author | Lioncash <[email protected]> | 2021-07-27 08:28:59 -0400 |
---|---|---|
committer | Rodrigo Locatti <[email protected]> | 2021-07-27 22:11:21 -0300 |
commit | 8cfe8badf70a7da0fa41e7f236bd6c5e52fa41ff (patch) | |
tree | 583fd0cc91e2575e40f3563b16180620c323be1f | |
parent | a39596358a3a5488c06554c0c15184a6af71e433 (diff) | |
download | sirit-8cfe8badf70a7da0fa41e7f236bd6c5e52fa41ff.tar.gz sirit-8cfe8badf70a7da0fa41e7f236bd6c5e52fa41ff.zip |
sirit: Add TypeSInt/TypeUInt helpers
Provides shorthands for specific signedness, so that usage code doesn't
need to explicitly use raw booleans.
TypeUInt(32), is easier to gloss than TypeInt(32, false), especially for
those not familiar with the API.
-rw-r--r-- | include/sirit/sirit.h | 6 | ||||
-rw-r--r-- | src/instructions/type.cpp | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index 3baa56f..589ea06 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -125,6 +125,12 @@ public: /// Returns type integer. Id TypeInt(int width, bool is_signed); + /// Returns type signed integer. + Id TypeSInt(int width); + + /// Returns type unsigned integer. + Id TypeUInt(int width); + /// Returns type float. Id TypeFloat(int width); diff --git a/src/instructions/type.cpp b/src/instructions/type.cpp index c3d04a0..3509d1f 100644 --- a/src/instructions/type.cpp +++ b/src/instructions/type.cpp @@ -28,6 +28,14 @@ Id Module::TypeInt(int width, bool is_signed) { return *declarations << OpId{spv::Op::OpTypeInt} << width << is_signed << EndOp{}; } +Id Module::TypeSInt(int width) { + return TypeInt(width, true); +} + +Id Module::TypeUInt(int width) { + return TypeInt(width, false); +} + Id Module::TypeFloat(int width) { declarations->Reserve(3); return *declarations << OpId{spv::Op::OpTypeFloat} << width << EndOp{}; |