transitive-closure.uir 1.46 KB
Newer Older
Kunshan Wang's avatar
Kunshan Wang committed
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
.typedef @i8  = int<8>
.typedef @i16 = int<16>
.typedef @i32 = int<32>
.typedef @i64 = int<64>
.typedef @f = float
.typedef @d = double

.typedef @foo = int<64>

.typedef @refi64 = ref<@i64>

.funcsig @s1 = (@i32) -> (@i16)

.const @F <@f> = 1.5f

.typedef @s = struct <@i64 @i64 @i32>
.const @S0 <@i64> = 0
.const @S1 <@i64> = 1
.const @S2 <@i32> = 2
.const @S  <@s>   = {@S0 @S1 @S2}

.global @gfoo <@foo>

.funcdecl @fd <@s1>

.funcsig @s2 = (@i16) -> (@i64)
.funcdef @gd VERSION %1 <@s2> {
    %entry(<@i16> %x):
        %b = ADD <@i64> @S0 @S1
        %c = ADD <@i16> %x %x
        COMMINST @uvm.thread_exit
}

.expose @ef = @fd #DEFAULT @S1
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

// linked list
.typedef @ll = struct <@i64 @refll>
.typedef @refll = ref<@ll>

.global @llhead <@refll>

// refer to head via refvoid. The object's concrete type should be scanned.
.typedef @void = void
.typedef @refvoid = ref<@void>
.global @llhead_void <@refvoid>

// refer to another global cell
.typedef @irefi64 = iref<@i64>
.global @gr1 <@i64>
.global @gr2 <@irefi64>
51

Kunshan Wang's avatar
Kunshan Wang committed
52 53 54 55 56 57 58
.funcsig @getchar.sig = (@i32) -> ()
.typedef @getchar.fp  = ufuncptr<@getchar.sig>

.typedef @s3 = struct<@i32 @pi32 @pi32 @getchar.fp>
.typedef @pi32 = uptr<@i32>
.global @gs3 <@s3>
.global @gs <@s>
59

60 61 62
.typedef @ppi32 = uptr<@pi32>
.global @gt <@ppi32>

63 64 65 66 67 68 69 70 71
.typedef @pi8 = uptr<@i8>
.typedef @ppi8 = uptr<@pi8>

.funcsig @main.sig = (@i32 @ppi8) -> (@i32)

.funcdef @main VERSION %v1 <@main.sig> {
    %entry(<@i32> %argc <@ppi8> %argv):
        COMMINST @uvm.thread_exit
}