blob: 2ba4388d197c5ff3ec86fb7d578290a605aa1508 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// test multiple uses of the threadPool
#include <iostream>
#include <ir/bits.h>
#include <ir/cost.h>
#include <wasm.h>
using namespace wasm;
void compare(size_t x, size_t y) {
if (x != y) {
std::cout << "comparison error!\n" << x << '\n' << y << '\n';
abort();
}
}
void test_bits() {
Const c;
c.type = Type::i32;
c.value = Literal(int32_t(1));
compare(Bits::getMaxBits(&c), 1);
c.value = Literal(int32_t(2));
compare(Bits::getMaxBits(&c), 2);
c.value = Literal(int32_t(3));
compare(Bits::getMaxBits(&c), 2);
}
void test_cost() {
// Some optimizations assume that the cost of a get is zero, e.g. local-cse.
LocalGet get;
compare(CostAnalyzer(&get).cost, 0);
}
int main() {
test_bits();
test_cost();
std::cout << "Success.\n";
return 0;
}
|