amd64_spec.pl 20.6 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
		"init_amd64_attributes(res, irn_flags, in_reqs, n_res, AMD64_OP_NONE);\n"
Matthias Braun's avatar
Matthias Braun committed
80
		."\tinit_amd64_switch_attributes(res, table, table_entity);",
81
	amd64_cc_attr_t =>
82
		"init_amd64_attributes(res, irn_flags, in_reqs, n_res, AMD64_OP_NONE);\n"
Andreas Fried's avatar
Andreas Fried committed
83
		."\tinit_amd64_cc_attributes(res, cc, insn_mode);",
84
	amd64_movimm_attr_t =>
85
		"init_amd64_attributes(res, irn_flags, in_reqs, n_res, AMD64_OP_IMM64);\n"
Matthias Braun's avatar
Matthias Braun committed
86
		."\tinit_amd64_movimm_attributes(res, insn_mode, imm);",
Matthias Braun's avatar
Matthias Braun committed
87
	amd64_shift_attr_t =>
88
		"be_info_init_irn(res, irn_flags, in_reqs, n_res);\n"
Matthias Braun's avatar
Matthias Braun committed
89
		."\t*attr = *attr_init;\n",
90
91
92
	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
93
94
95
96
97
98
99
100
101
102
103
	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",
104
105
);

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

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

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

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
143
144
145
	irn_flags => [ "modify_flags" ],
	state     => "exc_pinned",
	in_reqs   => "...",
146
	out_reqs  => [ "rax", "flags", "mem", "rdx" ],
147
148
149
	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",
150
151
152
};

my $shiftop = {
153
154
155
156
157
158
	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",
159
160
161
};

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

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

182
183
184
my $binopx = {
	irn_flags => [ "rematerializable" ],
	state     => "exc_pinned",
185
	in_reqs   => "...",
186
	out_reqs  => [ "xmm", "none", "mem" ],
187
188
189
190
191
192
193
194
	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",
195
	in_reqs   => "...",
196
	out_reqs  => [ "xmm", "none", "mem" ],
197
198
199
200
201
202
203
	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",
204
	in_reqs   => "...",
205
	out_reqs  => [ "xmm", "none", "mem" ],
206
207
208
209
210
211
212
	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",
213
	in_reqs   => "...",
214
	out_reqs  => [ "gp", "none", "mem" ],
215
216
217
218
219
220
221
	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",
222
	in_reqs   => "...",
223
	outs      => [ "res", "none", "M" ],
224
	out_reqs  => [ "xmm", "none", "mem" ],
225
226
227
228
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_op_mode_t op_mode, amd64_addr_t addr",
};

Matthias Braun's avatar
Matthias Braun committed
229
230
231
232
233
234
235
236
237
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
238
239
240
241
242
243
244
245
246
my $x87unop = {
	irn_flags => [ "rematerializable" ],
	in_reqs   => [ "x87" ],
	out_reqs  => [ "x87" ],
	ins       => [ "value" ],
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_X87;\n",
	mode      => $mode_x87,
};

247
%nodes = (
248
push_am => {
249
	op_flags  => [ "uses_memory" ],
250
	state     => "exc_pinned",
251
	in_reqs   => "...",
252
	out_reqs  => [ "rsp:I", "mem" ],
253
	outs      => [ "stack", "M" ],
Matthias Braun's avatar
Matthias Braun committed
254
255
256
	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
257
	emit      => "push%M %A",
258
259
},

260
push_reg => {
261
262
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
263
264
265
266
	in_reqs   => [ "rsp",   "mem", "gp"  ],
	ins       => [ "stack", "mem", "val" ],
	out_reqs  => [ "rsp:I", "mem" ],
	outs      => [ "stack", "M"   ],
267
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
268
	emit      => "pushq %^S2",
269
270
},

271
pop_am => {
272
273
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
274
	in_reqs   => "...",
275
	out_reqs  => [ "rsp:I", "mem" ],
276
	outs      => [ "stack", "M" ],
Matthias Braun's avatar
Matthias Braun committed
277
278
279
	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
280
	emit      => "pop%M %A",
281
},
282

283
sub_sp => {
284
	irn_flags => [ "modify_flags" ],
Tobias Rapp's avatar
Tobias Rapp committed
285
	state     => "pinned",
286
	in_reqs   => "...",
287
	out_reqs  => [ "rsp:I", "gp", "mem" ],
288
	ins       => [ "stack" ],
Tobias Rapp's avatar
Tobias Rapp committed
289
290
291
292
293
294
295
	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",
},

296
leave => {
297
298
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
299
300
301
	in_reqs   => [ "rbp", "mem" ],
	out_reqs  => [ "rbp:I", "mem", "rsp:I" ],
	outs      => [ "frame", "M",   "stack" ],
302
303
304
305
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
	emit      => "leave",
},

306
add => {
307
308
	template => $binop_commutative,
	emit     => "add%M %AM",
309
},
310

311
and => {
312
313
	template => $binop_commutative,
	emit     => "and%M %AM",
314
},
Matthias Braun's avatar
Matthias Braun committed
315

316
div => {
317
318
	template => $divop,
	emit     => "div%M %AM",
Matthias Braun's avatar
Matthias Braun committed
319
320
},

321
idiv => {
322
323
	template => $divop,
	emit     => "idiv%M %AM",
Matthias Braun's avatar
Matthias Braun committed
324
325
},

326
imul => {
327
328
	template => $binop_commutative,
	emit     => "imul%M %AM",
329
},
330

331
imul_1op => {
332
333
	template => $mulop,
	emit     => "imul%M %AM",
334
335
},

336
mul => {
337
338
	template => $mulop,
	emit     => "mul%M %AM",
339
340
},

341
or => {
342
343
	template => $binop_commutative,
	emit     => "or%M %AM",
344
345
},

346
shl => {
347
348
	template => $shiftop,
	emit     => "shl%MS %SO",
349
350
},

351
shr => {
352
353
	template => $shiftop,
	emit     => "shr%MS %SO",
354
355
},

356
sar => {
357
358
	template => $shiftop,
	emit     => "sar%MS %SO",
359
360
},

361
sub => {
362
	template  => $binop,
yb9976's avatar
yb9976 committed
363
	irn_flags => [ "modify_flags", "rematerializable" ],
364
	emit      => "sub%M %AM",
365
},
366

367
sbb => {
368
369
	template => $binop,
	emit     => "sbb%M %AM",
370
371
},

372
neg => {
373
374
	template => $unop,
	emit     => "neg%M %AM",
375
},
376

377
not => {
378
379
	template => $unop,
	emit     => "not%M %AM",
Christoph Mallon's avatar
Christoph Mallon committed
380
381
},

382
xor => {
383
384
	template => $binop_commutative,
	emit     => "xor%M %AM",
385
386
},

387
xor_0 => {
Matthias Braun's avatar
Matthias Braun committed
388
	op_flags  => [ "constlike" ],
389
	irn_flags => [ "modify_flags", "rematerializable" ],
390
	out_reqs  => [ "gp", "flags" ],
391
	outs      => [ "res", "flags" ],
392
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;",
Matthias Braun's avatar
Matthias Braun committed
393
	emit      => "xorl %3D0, %3D0",
Matthias Braun's avatar
Matthias Braun committed
394
395
},

396
mov_imm => {
397
	op_flags  => [ "constlike" ],
398
	irn_flags => [ "rematerializable" ],
399
	out_reqs  => [ "gp" ],
Matthias Braun's avatar
Matthias Braun committed
400
	attr_type => "amd64_movimm_attr_t",
Matthias Braun's avatar
Matthias Braun committed
401
	attr      => "amd64_insn_mode_t insn_mode, const amd64_imm64_t *imm",
Matthias Braun's avatar
Matthias Braun committed
402
	emit      => 'mov%MM $%C, %D0',
403
},
404

405
movs => {
406
	state     => "exc_pinned",
407
	in_reqs   => "...",
408
	out_reqs  => [ "gp", "none", "mem" ],
Matthias Braun's avatar
Matthias Braun committed
409
	outs      => [ "res", "unused", "M" ],
Matthias Braun's avatar
Matthias Braun committed
410
411
	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
412
413
414
	emit      => "movs%Mq %AM, %^D0",
},

415
mov_gp => {
Matthias Braun's avatar
Matthias Braun committed
416
	state     => "exc_pinned",
417
	in_reqs   => "...",
418
	out_reqs  => [ "gp", "none", "mem" ],
Matthias Braun's avatar
Matthias Braun committed
419
	outs      => [ "res", "unused", "M" ],
Matthias Braun's avatar
Matthias Braun committed
420
421
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
422
},
423

424
ijmp => {
425
426
	state     => "pinned",
	op_flags  => [ "cfopcode", "unknown_jump" ],
427
	in_reqs   => "...",
428
	out_reqs  => [ "exec", "none", "mem" ],
429
	outs      => [ "X", "unused", "M" ],
430
	attr_type => "amd64_addr_attr_t",
431
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
432
	emit      => "jmp %*AM",
433
434
},

435
jmp => {
Matthias Braun's avatar
Matthias Braun committed
436
437
	state    => "pinned",
	op_flags => [ "cfopcode" ],
438
	out_reqs => [ "exec" ],
439
	fixed    => "amd64_op_mode_t op_mode = AMD64_OP_NONE;",
440
},
441

442
cmp => {
443
	irn_flags => [ "modify_flags", "rematerializable" ],
444
	state     => "exc_pinned",
445
	in_reqs   => "...",
446
	out_reqs  => [ "none", "flags", "mem" ],
Matthias Braun's avatar
Matthias Braun committed
447
	outs      => [ "dummy", "flags", "M" ],
Matthias Braun's avatar
Matthias Braun committed
448
449
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Matthias Braun's avatar
Matthias Braun committed
450
	emit      => "cmp%M %AM",
451
},
452

453
454
455
456
457
458
459
460
461
462
463
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
464
465
466
467
468
469
470
471
472
473
474
475
476
# 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",
},

477
lea => {
Matthias Braun's avatar
Matthias Braun committed
478
	irn_flags => [ "rematerializable" ],
479
	in_reqs   => "...",
480
	outs      => [ "res" ],
481
	out_reqs  => [ "gp" ],
Matthias Braun's avatar
Matthias Braun committed
482
483
484
	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
485
	emit      => "lea%M %A, %D0",
Matthias Braun's avatar
Matthias Braun committed
486
487
},

488
jcc => {
489
	state     => "pinned",
490
	op_flags  => [ "cfopcode", "forking" ],
491
	in_reqs   => [ "eflags" ],
492
	out_reqs  => [ "exec", "exec" ],
493
494
	ins       => [ "eflags" ],
	outs      => [ "false", "true" ],
495
	attr_type => "amd64_cc_attr_t",
Matthias Braun's avatar
Matthias Braun committed
496
	attr      => "x86_condition_code_t cc",
Andreas Fried's avatar
Andreas Fried committed
497
	fixed     => "amd64_insn_mode_t insn_mode = INSN_MODE_64;",
498
},
499

500
mov_store => {
501
	op_flags  => [ "uses_memory" ],
502
	state     => "exc_pinned",
503
	in_reqs   => "...",
504
	out_reqs  => [ "mem" ],
505
	outs      => [ "M" ],
Matthias Braun's avatar
Matthias Braun committed
506
507
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
508
	emit      => "mov%M %AM",
509
},
510

511
jmp_switch => {
Matthias Braun's avatar
Matthias Braun committed
512
513
	op_flags  => [ "cfopcode", "forking" ],
	state     => "pinned",
514
	in_reqs   => [ "gp" ],
515
	out_reqs  => "...",
Matthias Braun's avatar
Matthias Braun committed
516
517
	attr_type => "amd64_switch_jmp_attr_t",
	attr      => "const ir_switch_table *table, ir_entity *table_entity",
518
519
},

520
call => {
521
	irn_flags => [ "modify_flags" ],
522
	state     => "exc_pinned",
523
	in_reqs   => "...",
524
	out_reqs  => "...",
525
	outs      => [ "M", "stack", "flags", "first_result" ],
526
527
	attr_type => "amd64_call_addr_attr_t",
	attr      => "const amd64_call_addr_attr_t *attr_init",
528
	emit      => "call %*AM",
529
530
},

531
ret => {
Matthias Braun's avatar
Matthias Braun committed
532
	state    => "pinned",
533
	op_flags => [ "cfopcode" ],
534
	in_reqs  => "...",
535
	out_reqs => [ "exec" ],
536
	ins      => [ "mem", "stack", "first_result" ],
Matthias Braun's avatar
Matthias Braun committed
537
	fixed    => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
538
	emit     => "ret",
539
540
},

541
542
bsf => {
	template => $unop_out,
543
	emit => "bsf%M %AM, %D0",
544
545
546
547
},

bsr => {
	template => $unop_out,
548
	emit => "bsr%M %AM, %D0",
549
550
},

551
552
# SSE

553
adds => {
554
555
	template => $binopx_commutative,
	emit     => "adds%MX %AM",
556
557
},

558
divs => {
559
560
	template => $binopx,
	emit     => "divs%MX %AM",
561
562
},

563
movs_xmm => {
564
565
566
	template => $movopx,
	attr     => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
	emit     => "movs%MX %AM, %D0",
567
568
},

569
muls => {
570
571
	template => $binopx_commutative,
	emit     => "muls%MX %AM",
Tobias Rapp's avatar
Tobias Rapp committed
572
573
},

574
movs_store_xmm => {
575
576
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
577
	in_reqs   => "...",
578
	out_reqs  => [ "mem" ],
579
580
581
	outs      => [ "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
582
	emit      => "movs%MX %^S0, %A",
583
584
},

585
subs => {
586
587
	template => $binopx,
	emit     => "subs%MX %AM",
588
589
},

590
ucomis => {
591
	irn_flags => [ "modify_flags", "rematerializable" ],
Tobias Rapp's avatar
Tobias Rapp committed
592
	state     => "exc_pinned",
593
	in_reqs   => "...",
594
	out_reqs  => [ "none", "flags", "mem" ],
Tobias Rapp's avatar
Tobias Rapp committed
595
596
597
598
599
600
	outs      => [ "dummy", "flags", "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "ucomis%MX %AM",
},

601
xorpd_0 => {
602
603
	op_flags  => [ "constlike" ],
	irn_flags => [ "rematerializable" ],
604
	out_reqs  => [ "xmm" ],
605
	outs      => [ "res" ],
606
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;",
607
	emit      => "xorpd %^D0, %^D0",
608
609
},

610
xorp => {
611
612
	template => $binopx_commutative,
	emit     => "xorp%MX %AM",
613
614
},

615
616
617
618
movd_xmm_gp => {
	state     => "exc_pinned",
	ins       => [ "operand" ],
	outs      => [ "res" ],
619
	in_reqs   => [ "xmm" ],
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
	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"
},

637
638
# Conversion operations

639
cvtss2sd => {
640
641
	template => $cvtop2x,
	emit     => "cvtss2sd %AM, %^D0",
642
643
},

644
cvtsd2ss => {
645
646
647
648
	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",
649
650
},

651
cvttsd2si => {
652
653
	template => $cvtopx2i,
	emit     => "cvttsd2si %AM, %D0",
654
655
},

656
cvttss2si => {
657
658
	template => $cvtopx2i,
	emit     => "cvttss2si %AM, %D0",
659
660
},

661
cvtsi2ss => {
662
663
	template => $cvtop2x,
	emit     => "cvtsi2ss %AM, %^D0",
664
665
},

666
cvtsi2sd => {
667
668
	template => $cvtop2x,
	emit     => "cvtsi2sd %AM, %^D0",
669
670
},

671
movq => {
672
673
674
	template => $movopx,
	fixed    => "amd64_insn_mode_t insn_mode = INSN_MODE_64;\n",
	emit     => "movq %AM, %D0",
675
676
},

677
movdqa => {
678
679
680
	template => $movopx,
	fixed    => "amd64_insn_mode_t insn_mode = INSN_MODE_128;\n",
	emit     => "movdqa %AM, %D0",
681
682
},

683
movdqu => {
684
685
686
	template => $movopx,
	fixed    => "amd64_insn_mode_t insn_mode = INSN_MODE_128;\n",
	emit     => "movdqu %AM, %D0",
687
688
689
690
691
},

movdqu_store => {
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
692
	in_reqs   => "...",
693
	out_reqs  => [ "mem" ],
694
695
696
697
698
699
	outs      => [ "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "movdqu %^S0, %A",
},

700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
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 => {
725
726
	template => $binopx,
	emit     => "punpckldq %AM",
727
728
729
},

subpd => {
730
731
	template => $binopx,
	emit     => "subpd %AM",
732
733
734
},

haddpd => {
735
736
	template => $binopx,
	emit     => "haddpd %AM",
737
738
},

Matthias Braun's avatar
Matthias Braun committed
739
740
741
742
743
744
745
746
747
748
fldz => {
	template => $x87const,
	emit     => "fldz",
},

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

749
750
751
752
753
754
755
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
756
	attr_type => "amd64_x87_addr_attr_t",
757
758
759
760
	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
761
762
763
764
765
766
fst => {
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
	in_reqs   => "...",
	out_reqs  => [ "mem" ],
	outs      => [ "M" ],
Matthias Braun's avatar
Matthias Braun committed
767
	attr_type => "amd64_x87_binop_addr_attr_t",
Matthias Braun's avatar
Matthias Braun committed
768
769
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	mode      => "mode_M",
Matthias Braun's avatar
Matthias Braun committed
770
771
772
773
774
775
776
777
778
779
780
781
782
	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
783
784
},

Matthias Braun's avatar
Matthias Braun committed
785
786
787
788
789
fchs => {
	template => $x87unop,
	emit     => "fchs",
},

Matthias Braun's avatar
Matthias Braun committed
790
791
792
793
794
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
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",
},

820
);