summaryrefslogtreecommitdiff
path: root/test/c/config_register.c
blob: 6b9b1021968f61d9189e8e20ce7d9e528c375fe2 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#include "sail.h"
#include "rts.h"
#include "elf.h"

// union option
enum kind_zoption { Kind_zNone };

struct zoption {
  enum kind_zoption kind;
  union {struct { unit zNone; };};
};

static void CREATE(zoption)(struct zoption *op)
{
  op->kind = Kind_zNone;
  
}

static void RECREATE(zoption)(struct zoption *op) {}

static void KILL(zoption)(struct zoption *op)
{
  if (op->kind == Kind_zNone){
    /* do nothing */
  };
}

static void COPY(zoption)(struct zoption *rop, struct zoption op)
{
  if (rop->kind == Kind_zNone){
    /* do nothing */
  };
  rop->kind = op.kind;
  if (op.kind == Kind_zNone){
    rop->zNone = op.zNone;
  }
}

static bool EQUAL(zoption)(struct zoption op1, struct zoption op2) {
  if (op1.kind == Kind_zNone && op2.kind == Kind_zNone) {
    return EQUAL(unit)(op1.zNone, op2.zNone);
  } else return false;
}

static void zNone(struct zoption *rop, unit op)
{
  if (rop->kind == Kind_zNone){
    /* do nothing */
  }
  rop->kind = Kind_zNone;
  rop->zNone = op;
}





























void zzzeros(sail_bits *rop, sail_int, unit);

void zzzeros(sail_bits *zgsz31, sail_int zn__tv, unit zgsz30)
{
  __label__ end_function_1, end_block_exception_2;

  zeros(*(&zgsz31), zn__tv);
end_function_1: ;
end_block_exception_2: ;
}

// register R
mach_bits zR;

// register S
mach_bits zS;

unit zmain(unit);

sail_bits zghz30;
sail_int zghz31;
sail_bits zghz32;

void startup_zmain(void)
{
  CREATE(sail_bits)(&zghz30);
  CREATE(sail_int)(&zghz31);
  CREATE(sail_bits)(&zghz32);
}

unit zmain(unit zgsz34)
{
  __label__ end_block_exception_4;

  unit zgsz39;
  {
    RECREATE_OF(sail_int, mach_int)(&zghz31, 32l);
    {
      /* copy call */
      RECREATE(sail_bits)(&zghz32);
      zzzeros(&zghz32, zghz31, UNIT);
      zR = CONVERT_OF(mach_bits, sail_bits)(zghz32, true);
    }
    unit zgsz37;
    zgsz37 = UNIT;
  }
  RECREATE_OF(sail_bits, mach_bits)(&zghz30, zR, UINT64_C(32) , true);
  zgsz39 = print_bits("R = ", zghz30);
  /* early return cleanup */
  return zgsz39;
end_block_exception_4: ;

  return UNIT;
}



void finish_zmain(void)
{
  KILL(sail_bits)(&zghz32);
  KILL(sail_int)(&zghz31);
  KILL(sail_bits)(&zghz30);
}

unit zinitializze_registers(unit);

unit zinitializze_registers(unit zgsz311)
{
  __label__ end_block_exception_6;

  unit zgsz313;
  mach_bits zgsz312;
  {    zgsz312 = UINT64_C(0);
  }
  zS = UINT64_C(0);
  zgsz313 = UNIT;

  /* early return cleanup */
  return zgsz313;
end_block_exception_6: ;

  return UNIT;
}

void model_init(void)
{
  setup_rts();
  startup_zmain();
  sail_int zgsz32;
  CREATE_OF(sail_int, mach_int)(&zgsz32, 32l);
  {
    /* copy call */
    sail_bits zgsz33;
    CREATE(sail_bits)(&zgsz33);
    zzzeros(&zgsz33, zgsz32, UNIT);
    zR = CONVERT_OF(mach_bits, sail_bits)(zgsz33, true);
    KILL(sail_bits)(&zgsz33);
  }
  KILL(sail_int)(&zgsz32);
  zinitializze_registers(UNIT);
}

void model_fini(void)
{
  finish_zmain();
  cleanup_rts();
}

int model_main(int argc, char *argv[])
{
  model_init();
  if (process_arguments(argc, argv)) exit(EXIT_FAILURE);
  zmain(UNIT);
  model_fini();
  return EXIT_SUCCESS;
}

int main(int argc, char *argv[])
{
  return model_main(argc, argv);
}