1
0
Fork 0
mirror of https://git.suyu.dev/suyu/sirit.git synced 2024-12-22 04:02:03 +00:00

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.
This commit is contained in:
Lioncash 2021-07-27 08:28:59 -04:00 committed by Rodrigo Locatti
parent a39596358a
commit 8cfe8badf7
2 changed files with 14 additions and 0 deletions

View file

@ -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);

View file

@ -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{};