amd64_spec.pl 21.4 KB
Newer Older
1
2
$arch = "amd64";

3
4
5
$mode_gp    = "mode_Lu";
$mode_flags = "mode_Iu";
$mode_xmm   = "amd64_mode_xmm";
Matthias Braun's avatar
Matthias Braun committed
6
$mode_x87   = "x86_mode_E";
7

8
9
%reg_classes = (
	gp => [
10
11
12
13
14
15
16
		{ name => "rax", dwarf => 0 },
		{ name => "rcx", dwarf => 2 },
		{ name => "rdx", dwarf => 1 },
		{ name => "rsi", dwarf => 4 },
		{ name => "rdi", dwarf => 5 },
		{ name => "rbx", dwarf => 3 },
		{ name => "rbp", dwarf => 6 },
17
		{ name => "rsp", dwarf => 7 },
18
19
20
21
22
23
24
25
		{ name => "r8",  dwarf => 8 },
		{ name => "r9",  dwarf => 9 },
		{ name => "r10", dwarf => 10 },
		{ name => "r11", dwarf => 11 },
		{ name => "r12", dwarf => 12 },
		{ name => "r13", dwarf => 13 },
		{ name => "r14", dwarf => 14 },
		{ name => "r15", dwarf => 15 },
26
		{ mode => $mode_gp }
27
	],
28
	flags => [
29
		{ name => "eflags", dwarf => 49 },
30
		{ mode => $mode_flags, flags => "manual_ra" }
31
	],
32
	xmm => [
Matthias Braun's avatar
Matthias Braun committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
		{ name => "xmm0",  dwarf => 17 },
		{ name => "xmm1",  dwarf => 18 },
		{ name => "xmm2",  dwarf => 19 },
		{ name => "xmm3",  dwarf => 20 },
		{ name => "xmm4",  dwarf => 21 },
		{ name => "xmm5",  dwarf => 22 },
		{ name => "xmm6",  dwarf => 23 },
		{ name => "xmm7",  dwarf => 24 },
		{ name => "xmm8",  dwarf => 25 },
		{ name => "xmm9",  dwarf => 26 },
		{ name => "xmm10", dwarf => 27 },
		{ name => "xmm11", dwarf => 28 },
		{ name => "xmm12", dwarf => 29 },
		{ name => "xmm13", dwarf => 30 },
		{ name => "xmm14", dwarf => 31 },
		{ name => "xmm15", dwarf => 32 },
49
		{ mode => $mode_xmm }
Matthias Braun's avatar
Matthias Braun committed
50
51
52
53
54
55
56
57
58
59
60
61
	],
	x87 => [
		{ name => "st0", realname => "st",    encoding => 0, dwarf => 11 },
		{ name => "st1", realname => "st(1)", encoding => 1, dwarf => 12 },
		{ name => "st2", realname => "st(2)", encoding => 2, dwarf => 13 },
		{ name => "st3", realname => "st(3)", encoding => 3, dwarf => 14 },
		{ name => "st4", realname => "st(4)", encoding => 4, dwarf => 15 },
		{ name => "st5", realname => "st(5)", encoding => 5, dwarf => 16 },
		{ name => "st6", realname => "st(6)", encoding => 6, dwarf => 17 },
		{ name => "st7", realname => "st(7)", encoding => 7, dwarf => 18 },
		{ mode => $mode_x87 }
	],
62
63
);

64
65
66
67
%custom_irn_flags = (
	commutative => "(arch_irn_flags_t)amd64_arch_irn_flag_commutative_binop",
);

68
%init_attr = (
Matthias Braun's avatar
Matthias Braun committed
69
	amd64_attr_t =>
70
		"init_amd64_attributes(res, irn_flags, in_reqs, n_res, op_mode);",
Matthias Braun's avatar
Matthias Braun committed
71
	amd64_addr_attr_t =>
72
		"init_amd64_attributes(res, irn_flags, in_reqs, n_res, op_mode);\n"
Matthias Braun's avatar
Matthias Braun committed
73
74
75
		."\tattr->insn_mode = insn_mode;\n"
		."\tattr->addr = addr;",
	amd64_binop_addr_attr_t =>
76
		"be_info_init_irn(res, irn_flags, in_reqs, n_res);\n"
Matthias Braun's avatar
Matthias Braun committed
77
		."\t*attr = *attr_init;",
78
	amd64_switch_jmp_attr_t =>
79
80
81
		"init_amd64_attributes(res, irn_flags, in_reqs, n_res, op_mode);\n"
		."\tattr->base.insn_mode = INSN_MODE_64;\n"
		."\tattr->base.addr = *addr;\n"
Matthias Braun's avatar
Matthias Braun committed
82
		."\tinit_amd64_switch_attributes(res, table, table_entity);",
83
	amd64_cc_attr_t =>
84
		"init_amd64_attributes(res, irn_flags, in_reqs, n_res, AMD64_OP_NONE);\n"
Andreas Fried's avatar
Andreas Fried committed
85
		."\tinit_amd64_cc_attributes(res, cc, insn_mode);",
86
	amd64_movimm_attr_t =>
87
		"init_amd64_attributes(res, irn_flags, in_reqs, n_res, AMD64_OP_IMM64);\n"
Matthias Braun's avatar
Matthias Braun committed
88
		."\tinit_amd64_movimm_attributes(res, insn_mode, imm);",
Matthias Braun's avatar
Matthias Braun committed
89
	amd64_shift_attr_t =>
90
		"be_info_init_irn(res, irn_flags, in_reqs, n_res);\n"
Matthias Braun's avatar
Matthias Braun committed
91
		."\t*attr = *attr_init;\n",
92
93
94
	amd64_call_addr_attr_t =>
		"be_info_init_irn(res, irn_flags, in_reqs, n_res);\n"
		."\t*attr = *attr_init;",
Matthias Braun's avatar
Matthias Braun committed
95
96
97
98
99
100
101
102
103
104
105
	amd64_x87_attr_t =>
		"init_amd64_attributes(res, irn_flags, in_reqs, n_res, AMD64_OP_X87);\n",
	amd64_x87_addr_attr_t =>
		"init_amd64_attributes(res, irn_flags, in_reqs, n_res, op_mode);\n"
		."\tattr->base.insn_mode = insn_mode;\n"
		."\tattr->base.addr      = addr;\n",
	amd64_x87_binop_addr_attr_t =>
		"be_info_init_irn(res, irn_flags, in_reqs, n_res);\n"
		."\tattr->base = *attr_init;\n"
		."\tassert(attr_init->base.base.op_mode == AMD64_OP_ADDR_REG);\n"
		."\tattr->base.base.base.op_mode = AMD64_OP_X87_ADDR_REG;\n",
106
107
);

108
my $binop = {
109
110
111
	irn_flags => [ "modify_flags" ],
	state     => "exc_pinned",
	in_reqs   => "...",
112
	out_reqs  => [ "gp", "flags", "mem" ],
113
114
115
	outs      => [ "res", "flags", "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
116
117
118
};

my $binop_commutative = {
119
120
121
	irn_flags => [ "modify_flags", "rematerializable", "commutative" ],
	state     => "exc_pinned",
	in_reqs   => "...",
122
	out_reqs  => [ "gp", "flags", "mem" ],
123
124
125
	outs      => [ "res", "flags", "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
126
127
128
};

my $divop = {
129
130
131
	irn_flags => [ "modify_flags" ],
	state     => "pinned",
	in_reqs   => "...",
132
	out_reqs  => [ "rax", "flags", "mem", "rdx" ],
133
134
	outs      => [ "res_div", "flags", "M", "res_mod" ],
	attr_type => "amd64_addr_attr_t",
135
	fixed     => "amd64_addr_t addr = { { .offset = 0 }, .variant = X86_ADDR_JUST_IMM };\n"
136
	            ."amd64_op_mode_t op_mode = AMD64_OP_REG;\n",
137
	attr      => "amd64_insn_mode_t insn_mode",
138
139
140
141
142
143
144
};

my $mulop = {
	# Do not rematerialize this node
	# TODO: should mark this commutative as soon as the backend code
	#       can handle this special case
	# It produces 2 results and has strict constraints
145
146
147
	irn_flags => [ "modify_flags" ],
	state     => "exc_pinned",
	in_reqs   => "...",
148
	out_reqs  => [ "rax", "flags", "mem", "rdx" ],
149
150
151
	outs      => [ "res_low", "flags", "M", "res_high" ],
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
152
153
154
};

my $shiftop = {
155
156
157
158
159
160
	irn_flags => [ "modify_flags", "rematerializable" ],
	in_reqs   => "...",
	out_reqs  => [ "gp", "flags" ],
	outs      => [ "res", "flags" ],
	attr_type => "amd64_shift_attr_t",
	attr      => "const amd64_shift_attr_t *attr_init",
161
162
163
};

my $unop = {
164
165
	irn_flags => [ "modify_flags", "rematerializable" ],
	in_reqs   => [ "gp" ],
166
	out_reqs  => [ "in_r0", "flags" ],
167
168
169
170
	ins       => [ "val" ],
	outs      => [ "res", "flags" ],
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode",
171
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_REG;\n"
172
	            ."amd64_addr_t addr = { { .offset = 0 }, .variant = X86_ADDR_JUST_IMM };",
173
174
};

175
176
my $unop_out = {
	irn_flags => [ "modify_flags", "rematerializable" ],
177
178
179
	in_reqs   => "...",
	out_reqs  => [ "gp", "flags", "mem" ],
	outs      => [ "res", "flags", "M" ],
180
181
182
183
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
};

184
185
186
my $binopx = {
	irn_flags => [ "rematerializable" ],
	state     => "exc_pinned",
187
	in_reqs   => "...",
188
	out_reqs  => [ "xmm", "none", "mem" ],
189
190
191
192
193
194
195
196
	outs      => [ "res", "none", "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
};

my $binopx_commutative = {
	irn_flags => [ "rematerializable", "commutative" ],
	state     => "exc_pinned",
197
	in_reqs   => "...",
198
	out_reqs  => [ "xmm", "none", "mem" ],
199
200
201
202
203
204
205
	outs      => [ "res", "none", "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
};

my $cvtop2x = {
	state     => "exc_pinned",
206
	in_reqs   => "...",
207
	out_reqs  => [ "xmm", "none", "mem" ],
208
209
210
211
212
213
214
	outs      => [ "res", "none", "M" ],
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
};

my $cvtopx2i = {
	state     => "exc_pinned",
215
	in_reqs   => "...",
216
	out_reqs  => [ "gp", "none", "mem" ],
217
218
219
220
221
222
223
	outs      => [ "res", "none", "M" ],
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
};

my $movopx = {
	state     => "exc_pinned",
224
	in_reqs   => "...",
225
	outs      => [ "res", "none", "M" ],
226
	out_reqs  => [ "xmm", "none", "mem" ],
227
228
229
230
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_op_mode_t op_mode, amd64_addr_t addr",
};

Matthias Braun's avatar
Matthias Braun committed
231
232
233
234
235
236
237
238
239
my $x87const = {
	op_flags  => [ "constlike" ],
	irn_flags => [ "rematerializable" ],
	out_reqs  => [ "x87" ],
	outs      => [ "res" ],
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_X87;\n",
	mode      => $mode_x87,
};

Matthias Braun's avatar
Matthias Braun committed
240
241
242
243
244
my $x87unop = {
	irn_flags => [ "rematerializable" ],
	in_reqs   => [ "x87" ],
	out_reqs  => [ "x87" ],
	ins       => [ "value" ],
245
246
247
248
249
250
251
252
253
254
255
	attr_type => "amd64_x87_attr_t",
	mode      => $mode_x87,
};

my $x87binop = {
	# TODO: AM variants
	irn_flags => [ "rematerializable" ],
	in_reqs   => [ "x87", "x87" ],
	out_reqs  => [ "x87" ],
	ins       => [ "left", "right" ],
	attr_type => "amd64_x87_attr_t",
Matthias Braun's avatar
Matthias Braun committed
256
257
258
	mode      => $mode_x87,
};

259
%nodes = (
260
push_am => {
261
	op_flags  => [ "uses_memory" ],
262
	state     => "exc_pinned",
263
	in_reqs   => "...",
264
	out_reqs  => [ "rsp:I", "mem" ],
265
	outs      => [ "stack", "M" ],
Matthias Braun's avatar
Matthias Braun committed
266
267
268
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_addr_t addr",
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_ADDR;\n",
Matthias Braun's avatar
Matthias Braun committed
269
	emit      => "push%M %A",
270
271
},

272
push_reg => {
273
274
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
275
276
277
278
	in_reqs   => [ "rsp",   "mem", "gp"  ],
	ins       => [ "stack", "mem", "val" ],
	out_reqs  => [ "rsp:I", "mem" ],
	outs      => [ "stack", "M"   ],
279
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
280
	emit      => "pushq %^S2",
281
282
},

283
pop_am => {
284
285
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
286
	in_reqs   => "...",
287
	out_reqs  => [ "rsp:I", "mem" ],
288
	outs      => [ "stack", "M" ],
Matthias Braun's avatar
Matthias Braun committed
289
290
291
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_addr_t addr",
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_ADDR;\n",
Matthias Braun's avatar
Matthias Braun committed
292
	emit      => "pop%M %A",
293
},
294

295
sub_sp => {
296
	irn_flags => [ "modify_flags" ],
Tobias Rapp's avatar
Tobias Rapp committed
297
	state     => "pinned",
298
	in_reqs   => "...",
299
	out_reqs  => [ "rsp:I", "gp", "mem" ],
300
	ins       => [ "stack" ],
Tobias Rapp's avatar
Tobias Rapp committed
301
302
303
304
305
306
307
	outs      => [ "stack", "addr", "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "subq %AM\n".
	             "movq %%rsp, %D1",
},

308
leave => {
309
310
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
311
312
313
	in_reqs   => [ "rbp", "mem" ],
	out_reqs  => [ "rbp:I", "mem", "rsp:I" ],
	outs      => [ "frame", "M",   "stack" ],
314
315
316
317
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
	emit      => "leave",
},

318
add => {
319
320
	template => $binop_commutative,
	emit     => "add%M %AM",
321
},
322

323
and => {
324
325
	template => $binop_commutative,
	emit     => "and%M %AM",
326
},
Matthias Braun's avatar
Matthias Braun committed
327

328
div => {
329
330
	template => $divop,
	emit     => "div%M %AM",
Matthias Braun's avatar
Matthias Braun committed
331
332
},

333
idiv => {
334
335
	template => $divop,
	emit     => "idiv%M %AM",
Matthias Braun's avatar
Matthias Braun committed
336
337
},

338
imul => {
339
340
	template => $binop_commutative,
	emit     => "imul%M %AM",
341
},
342

343
imul_1op => {
344
345
	template => $mulop,
	emit     => "imul%M %AM",
346
347
},

348
mul => {
349
350
	template => $mulop,
	emit     => "mul%M %AM",
351
352
},

353
or => {
354
355
	template => $binop_commutative,
	emit     => "or%M %AM",
356
357
},

358
shl => {
359
360
	template => $shiftop,
	emit     => "shl%MS %SO",
361
362
},

363
shr => {
364
365
	template => $shiftop,
	emit     => "shr%MS %SO",
366
367
},

368
sar => {
369
370
	template => $shiftop,
	emit     => "sar%MS %SO",
371
372
},

373
sub => {
374
	template  => $binop,
yb9976's avatar
yb9976 committed
375
	irn_flags => [ "modify_flags", "rematerializable" ],
376
	emit      => "sub%M %AM",
377
},
378

379
sbb => {
380
381
	template => $binop,
	emit     => "sbb%M %AM",
382
383
},

384
neg => {
385
386
	template => $unop,
	emit     => "neg%M %AM",
387
},
388

389
not => {
390
391
	template => $unop,
	emit     => "not%M %AM",
Christoph Mallon's avatar
Christoph Mallon committed
392
393
},

394
xor => {
395
396
	template => $binop_commutative,
	emit     => "xor%M %AM",
397
398
},

399
xor_0 => {
Matthias Braun's avatar
Matthias Braun committed
400
	op_flags  => [ "constlike" ],
401
	irn_flags => [ "modify_flags", "rematerializable" ],
402
	out_reqs  => [ "gp", "flags" ],
403
	outs      => [ "res", "flags" ],
404
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;",
Matthias Braun's avatar
Matthias Braun committed
405
	emit      => "xorl %3D0, %3D0",
Matthias Braun's avatar
Matthias Braun committed
406
407
},

408
mov_imm => {
409
	op_flags  => [ "constlike" ],
410
	irn_flags => [ "rematerializable" ],
411
	out_reqs  => [ "gp" ],
Matthias Braun's avatar
Matthias Braun committed
412
	attr_type => "amd64_movimm_attr_t",
Matthias Braun's avatar
Matthias Braun committed
413
	attr      => "amd64_insn_mode_t insn_mode, const amd64_imm64_t *imm",
Matthias Braun's avatar
Matthias Braun committed
414
	emit      => 'mov%MM $%C, %D0',
415
},
416

417
movs => {
418
	state     => "exc_pinned",
419
	in_reqs   => "...",
420
	out_reqs  => [ "gp", "none", "mem" ],
Matthias Braun's avatar
Matthias Braun committed
421
	outs      => [ "res", "unused", "M" ],
Matthias Braun's avatar
Matthias Braun committed
422
423
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
Matthias Braun's avatar
Matthias Braun committed
424
425
426
	emit      => "movs%Mq %AM, %^D0",
},

427
mov_gp => {
Matthias Braun's avatar
Matthias Braun committed
428
	state     => "exc_pinned",
429
	in_reqs   => "...",
430
	out_reqs  => [ "gp", "none", "mem" ],
Matthias Braun's avatar
Matthias Braun committed
431
	outs      => [ "res", "unused", "M" ],
Matthias Braun's avatar
Matthias Braun committed
432
433
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
434
},
435

436
ijmp => {
437
438
	state     => "pinned",
	op_flags  => [ "cfopcode", "unknown_jump" ],
439
	in_reqs   => "...",
440
	out_reqs  => [ "exec", "none", "mem" ],
441
	outs      => [ "X", "unused", "M" ],
442
	attr_type => "amd64_addr_attr_t",
443
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
444
	emit      => "jmp %*AM",
445
446
},

447
jmp => {
Matthias Braun's avatar
Matthias Braun committed
448
449
	state    => "pinned",
	op_flags => [ "cfopcode" ],
450
	out_reqs => [ "exec" ],
451
	fixed    => "amd64_op_mode_t op_mode = AMD64_OP_NONE;",
452
},
453

454
cmp => {
455
	irn_flags => [ "modify_flags", "rematerializable" ],
456
	state     => "exc_pinned",
457
	in_reqs   => "...",
458
	out_reqs  => [ "none", "flags", "mem" ],
Matthias Braun's avatar
Matthias Braun committed
459
	outs      => [ "dummy", "flags", "M" ],
Matthias Braun's avatar
Matthias Braun committed
460
461
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Matthias Braun's avatar
Matthias Braun committed
462
	emit      => "cmp%M %AM",
463
},
464

465
466
467
468
469
470
471
472
473
474
475
cmpxchg => {
	irn_flags => [ "modify_flags" ],
	state     => "exc_pinned",
	in_reqs   => "...",
	out_reqs  => [ "rax", "flags", "mem" ],
	outs      => [ "res", "flags", "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "lock cmpxchg%M %AM",
},

Andreas Fried's avatar
Andreas Fried committed
476
477
478
479
480
481
482
483
484
485
486
487
488
# TODO Setcc can also operate on memory
setcc => {
	irn_flags => [  ],
	in_reqs   => [ "eflags" ],
	out_reqs  => [ "gp" ],
	ins       => [ "eflags" ],
	outs      => [ "res" ],
	attr_type => "amd64_cc_attr_t",
	attr      => "x86_condition_code_t cc",
	fixed     => "amd64_insn_mode_t insn_mode = INSN_MODE_8;",
	emit      => "set%P0 %D0",
},

489
lea => {
Matthias Braun's avatar
Matthias Braun committed
490
	irn_flags => [ "rematerializable" ],
491
	in_reqs   => "...",
492
	outs      => [ "res" ],
493
	out_reqs  => [ "gp" ],
Matthias Braun's avatar
Matthias Braun committed
494
495
496
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_addr_t addr",
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_ADDR;\n",
Matthias Braun's avatar
Matthias Braun committed
497
	emit      => "lea%M %A, %D0",
Matthias Braun's avatar
Matthias Braun committed
498
499
},

500
jcc => {
501
	state     => "pinned",
502
	op_flags  => [ "cfopcode", "forking" ],
503
	in_reqs   => [ "eflags" ],
504
	out_reqs  => [ "exec", "exec" ],
505
506
	ins       => [ "eflags" ],
	outs      => [ "false", "true" ],
507
	attr_type => "amd64_cc_attr_t",
Matthias Braun's avatar
Matthias Braun committed
508
	attr      => "x86_condition_code_t cc",
Andreas Fried's avatar
Andreas Fried committed
509
	fixed     => "amd64_insn_mode_t insn_mode = INSN_MODE_64;",
510
},
511

512
mov_store => {
513
	op_flags  => [ "uses_memory" ],
514
	state     => "exc_pinned",
515
	in_reqs   => "...",
516
	out_reqs  => [ "mem" ],
517
	outs      => [ "M" ],
Matthias Braun's avatar
Matthias Braun committed
518
519
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
520
	emit      => "mov%M %AM",
521
},
522

523
jmp_switch => {
Matthias Braun's avatar
Matthias Braun committed
524
525
	op_flags  => [ "cfopcode", "forking" ],
	state     => "pinned",
526
	in_reqs   => "...",
527
	out_reqs  => "...",
Matthias Braun's avatar
Matthias Braun committed
528
	attr_type => "amd64_switch_jmp_attr_t",
529
	attr      => "amd64_op_mode_t op_mode, const amd64_addr_t *addr, const ir_switch_table *table, ir_entity *table_entity",
530
531
},

532
call => {
533
	irn_flags => [ "modify_flags" ],
534
	state     => "exc_pinned",
535
	in_reqs   => "...",
536
	out_reqs  => "...",
537
	outs      => [ "M", "stack", "flags", "first_result" ],
538
539
	attr_type => "amd64_call_addr_attr_t",
	attr      => "const amd64_call_addr_attr_t *attr_init",
540
	emit      => "call %*AM",
541
542
},

543
ret => {
Matthias Braun's avatar
Matthias Braun committed
544
	state    => "pinned",
545
	op_flags => [ "cfopcode" ],
546
	in_reqs  => "...",
547
	out_reqs => [ "exec" ],
548
	ins      => [ "mem", "stack", "first_result" ],
Matthias Braun's avatar
Matthias Braun committed
549
	fixed    => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
550
	emit     => "ret",
551
552
},

553
554
bsf => {
	template => $unop_out,
555
	emit => "bsf%M %AM, %D0",
556
557
558
559
},

bsr => {
	template => $unop_out,
560
	emit => "bsr%M %AM, %D0",
561
562
},

563
564
# SSE

565
adds => {
566
567
	template => $binopx_commutative,
	emit     => "adds%MX %AM",
568
569
},

570
divs => {
571
572
	template => $binopx,
	emit     => "divs%MX %AM",
573
574
},

575
movs_xmm => {
576
577
578
	template => $movopx,
	attr     => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
	emit     => "movs%MX %AM, %D0",
579
580
},

581
muls => {
582
583
	template => $binopx_commutative,
	emit     => "muls%MX %AM",
Tobias Rapp's avatar
Tobias Rapp committed
584
585
},

586
movs_store_xmm => {
587
588
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
589
	in_reqs   => "...",
590
	out_reqs  => [ "mem" ],
591
592
593
	outs      => [ "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
594
	emit      => "movs%MX %^S0, %A",
595
596
},

597
subs => {
598
599
	template => $binopx,
	emit     => "subs%MX %AM",
600
601
},

602
ucomis => {
603
	irn_flags => [ "modify_flags", "rematerializable" ],
Tobias Rapp's avatar
Tobias Rapp committed
604
	state     => "exc_pinned",
605
	in_reqs   => "...",
606
	out_reqs  => [ "none", "flags", "mem" ],
Tobias Rapp's avatar
Tobias Rapp committed
607
608
609
610
611
612
	outs      => [ "dummy", "flags", "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "ucomis%MX %AM",
},

613
xorpd_0 => {
614
615
	op_flags  => [ "constlike" ],
	irn_flags => [ "rematerializable" ],
616
	out_reqs  => [ "xmm" ],
617
	outs      => [ "res" ],
618
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;",
619
	emit      => "xorpd %^D0, %^D0",
620
621
},

622
xorp => {
623
624
	template => $binopx_commutative,
	emit     => "xorp%MX %AM",
625
626
},

627
628
629
630
movd_xmm_gp => {
	state     => "exc_pinned",
	ins       => [ "operand" ],
	outs      => [ "res" ],
631
	in_reqs   => [ "xmm" ],
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
	out_reqs  => [ "gp" ],
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
	emit      => "movd %S0, %D0"
},

movd_gp_xmm => {
	state     => "exc_pinned",
	ins       => [ "operand" ],
	outs      => [ "res" ],
	in_reqs   => [ "gp" ],
	out_reqs  => [ "xmm" ],
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
	emit      => "movd %S0, %D0"
},

649
650
# Conversion operations

651
cvtss2sd => {
652
653
	template => $cvtop2x,
	emit     => "cvtss2sd %AM, %^D0",
654
655
},

656
cvtsd2ss => {
657
658
659
660
	template => $cvtop2x,
	attr     => "amd64_op_mode_t op_mode, amd64_addr_t addr",
	fixed    => "amd64_insn_mode_t insn_mode = INSN_MODE_64;\n",
	emit     => "cvtsd2ss %AM, %^D0",
661
662
},

663
cvttsd2si => {
664
665
	template => $cvtopx2i,
	emit     => "cvttsd2si %AM, %D0",
666
667
},

668
cvttss2si => {
669
670
	template => $cvtopx2i,
	emit     => "cvttss2si %AM, %D0",
671
672
},

673
cvtsi2ss => {
674
675
	template => $cvtop2x,
	emit     => "cvtsi2ss %AM, %^D0",
676
677
},

678
cvtsi2sd => {
679
680
	template => $cvtop2x,
	emit     => "cvtsi2sd %AM, %^D0",
681
682
},

683
movq => {
684
685
686
	template => $movopx,
	fixed    => "amd64_insn_mode_t insn_mode = INSN_MODE_64;\n",
	emit     => "movq %AM, %D0",
687
688
},

689
movdqa => {
690
691
692
	template => $movopx,
	fixed    => "amd64_insn_mode_t insn_mode = INSN_MODE_128;\n",
	emit     => "movdqa %AM, %D0",
693
694
},

695
movdqu => {
696
697
698
	template => $movopx,
	fixed    => "amd64_insn_mode_t insn_mode = INSN_MODE_128;\n",
	emit     => "movdqu %AM, %D0",
699
700
701
702
703
},

movdqu_store => {
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
704
	in_reqs   => "...",
705
	out_reqs  => [ "mem" ],
706
707
708
709
710
711
	outs      => [ "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "movdqu %^S0, %A",
},

712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
l_punpckldq => {
	ins       => [ "arg0", "arg1" ],
	outs      => [ "res" ],
	attr_type => "",
	dump_func => "NULL",
	mode      => $mode_xmm,
},

l_subpd => {
	ins       => [ "arg0", "arg1" ],
	outs      => [ "res" ],
	attr_type => "",
	dump_func => "NULL",
	mode      => $mode_xmm,
},

l_haddpd => {
	ins       => [ "arg0", "arg1" ],
	outs      => [ "res" ],
	attr_type => "",
	dump_func => "NULL",
	mode      => $mode_xmm,
},

punpckldq => {
737
738
	template => $binopx,
	emit     => "punpckldq %AM",
739
740
741
},

subpd => {
742
743
	template => $binopx,
	emit     => "subpd %AM",
744
745
746
},

haddpd => {
747
748
	template => $binopx,
	emit     => "haddpd %AM",
749
750
},

Matthias Braun's avatar
Matthias Braun committed
751
752
753
754
755
756
757
758
759
760
fldz => {
	template => $x87const,
	emit     => "fldz",
},

fld1 => {
	template => $x87const,
	emit     => "fld1",
},

761
762
763
764
765
766
767
fld => {
	irn_flags => [ "rematerializable" ],
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
	in_reqs   => "...",
	out_reqs  => [ "x87", "none", "mem" ],
	outs      => [ "res", "unused", "M" ],
Matthias Braun's avatar
Matthias Braun committed
768
	attr_type => "amd64_x87_addr_attr_t",
769
770
771
772
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
	emit      => "fld%FM %AM",
},

Matthias Braun's avatar
Matthias Braun committed
773
774
775
776
777
778
fst => {
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
	in_reqs   => "...",
	out_reqs  => [ "mem" ],
	outs      => [ "M" ],
Matthias Braun's avatar
Matthias Braun committed
779
	attr_type => "amd64_x87_binop_addr_attr_t",
Matthias Braun's avatar
Matthias Braun committed
780
781
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	mode      => "mode_M",
Matthias Braun's avatar
Matthias Braun committed
782
783
784
785
786
787
788
789
790
791
792
793
794
	emit      => "fst%FP%FM %AM",
},

fstp => {
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
	in_reqs   => "...",
	out_reqs  => [ "mem" ],
	outs      => [ "M" ],
	attr_type => "amd64_x87_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	mode      => "mode_M",
	emit      => "fstp%FM %AM",
Matthias Braun's avatar
Matthias Braun committed
795
796
},

797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
fadd => {
	template => $x87binop,
	emit     => "fadd%FP %AF",
},

fdiv => {
	template => $x87binop,
	emit     => "fdiv%FR%FP %AF",
	outs     => [ "res", "flags", "M" ],
	out_reqs => [ "x87", "flags", "mem" ],
	mode     => "mode_T",
},

fmul => {
	template => $x87binop,
	emit     => "fmul%FP %AF",
},

fsub => {
	template => $x87binop,
	emit     => "fadd%FR%FP %AF",
},

Matthias Braun's avatar
Matthias Braun committed
820
821
822
823
824
fchs => {
	template => $x87unop,
	emit     => "fchs",
},

825
826
827
828
829
830
831
832
833
834
fucomi => {
	irn_flags => [ "rematerializable" ],
	in_reqs   => [ "x87", "x87" ],
	out_reqs  => [ "flags" ],
	ins       => [ "left", "right" ],
	outs      => [ "flags" ],
	attr_type => "amd64_x87_attr_t",
	emit      => "fucom%FPi %F0",
},

Matthias Braun's avatar
Matthias Braun committed
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
fdup => {
	in_reqs     => [ "x87" ],
	out_reqs    => [ "x87" ],
	ins         => [ "val" ],
	attrs_equal => "attrs_equal_false",
	attr_type   => "amd64_x87_attr_t",
	attr        => "const arch_register_t *reg",
	init        => "attr->x87.reg = reg;",
	emit        => "fld %F0",
},

fxch => {
	op_flags    => [ "keep" ],
	out_reqs    => [ "none" ],
	attrs_equal => "attrs_equal_false",
	attr_type   => "amd64_x87_attr_t",
	attr        => "const arch_register_t *reg",
	init        => "attr->x87.reg = reg;",
	emit        => "fxch %F0",
},

fpop => {
	op_flags    => [ "keep" ],
	out_reqs    => [ "none" ],
	attr_type   => "amd64_x87_attr_t",
	attr        => "const arch_register_t *reg",
	init        => "attr->x87.reg = reg;",
	emit        => "fstp %F0",
},

865
);