Skip to content

Commit

Permalink
sirit: Add TypeSInt/TypeUInt helpers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lioncash authored and ReinUsesLisp committed Jul 28, 2021
1 parent a395963 commit 8cfe8ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/sirit/sirit.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ class Module {
/// 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);

Expand Down
8 changes: 8 additions & 0 deletions src/instructions/type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand Down

0 comments on commit 8cfe8ba

Please sign in to comment.