mirror of
https://gitee.com/openharmony/third_party_spirv-tools
synced 2024-11-23 23:39:40 +00:00
Add IsSigned() to opt::Analysis::Integer.
This commit is contained in:
parent
1773b95737
commit
049f80f3b9
@ -125,6 +125,7 @@ class Integer : public Type {
|
|||||||
Integer* AsInteger() override { return this; }
|
Integer* AsInteger() override { return this; }
|
||||||
const Integer* AsInteger() const override { return this; }
|
const Integer* AsInteger() const override { return this; }
|
||||||
uint32_t width() const { return width_; }
|
uint32_t width() const { return width_; }
|
||||||
|
bool IsSigned() const { return signed_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t width_; // bit width
|
uint32_t width_; // bit width
|
||||||
|
@ -208,6 +208,17 @@ TEST(Types, AllTypes) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Types, IntSignedness) {
|
||||||
|
std::vector<bool> signednesses = {true, false, false, true};
|
||||||
|
std::vector<std::unique_ptr<Integer>> types;
|
||||||
|
for (bool s : signednesses) {
|
||||||
|
types.emplace_back(new Integer(32, s));
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < signednesses.size(); i++) {
|
||||||
|
EXPECT_EQ(signednesses[i], types[i]->IsSigned());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST(Types, IntWidth) {
|
TEST(Types, IntWidth) {
|
||||||
std::vector<uint32_t> widths = {1, 2, 4, 8, 16, 32, 48, 64, 128};
|
std::vector<uint32_t> widths = {1, 2, 4, 8, 16, 32, 48, 64, 128};
|
||||||
std::vector<std::unique_ptr<Integer>> types;
|
std::vector<std::unique_ptr<Integer>> types;
|
||||||
|
Loading…
Reference in New Issue
Block a user