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

3
4
$mode_gp      = "mode_Lu";
$mode_flags   = "mode_Iu";
5
$mode_xmm     = "amd64_mode_xmm";
6
7
8
$status_flags = "all"; # TODO
$all_flags    = "all";

9
10
%reg_classes = (
	gp => [
11
12
13
14
15
16
17
		{ 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 },
18
		{ name => "rsp", dwarf => 7 },
19
20
21
22
23
24
25
26
		{ 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 },
27
		{ mode => $mode_gp }
28
	],
29
	flags => [
30
		{ name => "eflags", dwarf => 49 },
31
		{ mode => $mode_flags, flags => "manual_ra" }
32
	],
33
34
35
36
37
38
39
40
41
42
43
	xmm => [
		{ 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 },
		{ mode => $mode_xmm }
	]
44
45
);

46
47
48
49
50
51
52
sub amd64_custom_init_attr {
	my $constr = shift;
	my $node   = shift;
	my $name   = shift;
	my $res    = "";

	if(defined($node->{modified_flags})) {
53
		$res .= "\tarch_add_irn_flags(res, arch_irn_flag_modify_flags);\n";
54
55
56
57
58
	}
	return $res;
}
$custom_init_attr_func = \&amd64_custom_init_attr;

59
60
61
62
%custom_irn_flags = (
	commutative => "(arch_irn_flags_t)amd64_arch_irn_flag_commutative_binop",
);

63
64
$default_copy_attr = "amd64_copy_attr";

65
%init_attr = (
Matthias Braun's avatar
Matthias Braun committed
66
67
68
69
70
71
	amd64_attr_t =>
		"init_amd64_attributes(res, irn_flags_, in_reqs, n_res, op_mode);",
	amd64_addr_attr_t =>
		"init_amd64_attributes(res, irn_flags_, in_reqs, n_res, op_mode);\n"
		."\tattr->insn_mode = insn_mode;\n"
		."\tattr->addr = addr;",
72
73
74
	amd64_asm_attr_t =>
		"init_amd64_attributes(res, irn_flags_, in_reqs, n_res, op_mode);\n"
		."\tattr->asmattr = *asmattr;\n",
Matthias Braun's avatar
Matthias Braun committed
75
	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 =>
Matthias Braun's avatar
Matthias Braun committed
79
80
		"init_amd64_attributes(res, irn_flags_, in_reqs, n_res, op_mode);\n"
		."\tinit_amd64_switch_attributes(res, table, table_entity);",
81
	amd64_cc_attr_t =>
Matthias Braun's avatar
Matthias Braun committed
82
83
		"init_amd64_attributes(res, irn_flags_, in_reqs, n_res, op_mode);\n"
		."\tinit_amd64_cc_attributes(res, cc);",
84
	amd64_movimm_attr_t =>
Matthias Braun's avatar
Matthias Braun committed
85
86
87
		"init_amd64_attributes(res, irn_flags_, in_reqs, n_res, op_mode);\n"
		."\tinit_amd64_movimm_attributes(res, insn_mode, entity, offset);",
	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
);

%nodes = (
93
push_am => {
94
	op_flags  => [ "uses_memory" ],
95
	state     => "exc_pinned",
96
97
	reg_req   => { out => [ "rsp:I|S", "none" ] },
	arity     => "variable",
98
	outs      => [ "stack", "M" ],
Matthias Braun's avatar
Matthias Braun committed
99
100
101
	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
102
	emit      => "push%M %A",
103
104
},

105
push_rbp => {
106
107
108
109
110
111
112
113
114
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
	reg_req   => { in => [ "rsp" ], out => [ "rsp:I|S" ] },
	ins       => [ "stack" ],
	outs      => [ "stack" ],
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
	emit      => "pushq %%rbp",
},

115
pop_am => {
116
117
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
118
119
	reg_req   => { out => [ "rsp:I|S", "none" ] },
	arity     => "variable",
120
	outs      => [ "stack", "M" ],
Matthias Braun's avatar
Matthias Braun committed
121
122
123
	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
124
	emit      => "pop%M %A",
125
},
126

127
sub_sp => {
Tobias Rapp's avatar
Tobias Rapp committed
128
129
130
131
132
133
134
135
136
137
138
	state     => "pinned",
	reg_req   => { out => [ "rsp:I|S", "gp", "none" ] },
	outs      => [ "stack", "addr", "M" ],
	arity     => "variable",
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "subq %AM\n".
	             "movq %%rsp, %D1",
	modified_flags => $status_flags,
},

139
leave => {
140
141
142
143
144
145
146
147
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
	reg_req   => { in => [ "rbp" ], out => [ "rbp:I", "rbp:I|S" ] },
	outs      => [ "frame", "stack" ],
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
	emit      => "leave",
},

148
add => {
149
	irn_flags => [ "rematerializable", "commutative" ],
Matthias Braun's avatar
Matthias Braun committed
150
151
152
153
	state     => "exc_pinned",
	reg_req   => { out => [ "gp", "flags", "none" ] },
	arity     => "variable",
	outs      => [ "res", "flags", "M" ],
Matthias Braun's avatar
Matthias Braun committed
154
155
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Matthias Braun's avatar
Matthias Braun committed
156
157
	emit      => "add%M %AM",
	modified_flags => $status_flags,
158
},
159

160
and => {
161
	irn_flags => [ "rematerializable", "commutative" ],
Matthias Braun's avatar
Matthias Braun committed
162
163
164
165
	state     => "exc_pinned",
	reg_req   => { out => [ "gp", "flags", "none" ] },
	arity     => "variable",
	outs      => [ "res", "flags", "M" ],
Matthias Braun's avatar
Matthias Braun committed
166
167
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Matthias Braun's avatar
Matthias Braun committed
168
169
	emit      => "and%M %AM",
	modified_flags => $status_flags,
170
},
Matthias Braun's avatar
Matthias Braun committed
171

172
173
174
175
176
177
asm => {
	arity     => "variable",
	out_arity => "variable",
	attr_type => "amd64_asm_attr_t",
	attr      => "const x86_asm_attr_t *asmattr",
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
178
179
},

180
div => {
181
	state     => "pinned",
Matthias Braun's avatar
Matthias Braun committed
182
183
184
185
	reg_req   => { out => [ "rax", "flags", "none", "rdx" ] },
	arity     => "variable",
	outs      => [ "res_div", "flags", "M", "res_mod" ],
	attr_type => "amd64_addr_attr_t",
186
187
188
	fixed     => "amd64_addr_t addr = { { NULL, 0 }, NO_INPUT, NO_INPUT, NO_INPUT, 0, AMD64_SEGMENT_DEFAULT };\n"
	            ."amd64_op_mode_t op_mode = AMD64_OP_RAX_REG;\n",
	attr      => "amd64_insn_mode_t insn_mode",
189
	emit      => "div%M %AM",
190
	modified_flags => $status_flags,
Matthias Braun's avatar
Matthias Braun committed
191
192
},

193
idiv => {
194
	state     => "pinned",
Matthias Braun's avatar
Matthias Braun committed
195
196
197
198
	reg_req   => { out => [ "rax", "flags", "none", "rdx" ] },
	arity     => "variable",
	outs      => [ "res_div", "flags", "M", "res_mod" ],
	attr_type => "amd64_addr_attr_t",
199
200
201
	fixed     => "amd64_addr_t addr = { { NULL, 0 }, NO_INPUT, NO_INPUT, NO_INPUT, 0, AMD64_SEGMENT_DEFAULT };\n"
	            ."amd64_op_mode_t op_mode = AMD64_OP_RAX_REG;\n",
	attr      => "amd64_insn_mode_t insn_mode",
Matthias Braun's avatar
Matthias Braun committed
202
	emit      => "idiv%M %AM",
203
	modified_flags => $status_flags,
Matthias Braun's avatar
Matthias Braun committed
204
205
},

206
imul => {
207
	irn_flags => [ "rematerializable", "commutative" ],
Robin Redeker's avatar
Robin Redeker committed
208
	state     => "exc_pinned",
Matthias Braun's avatar
Matthias Braun committed
209
210
211
	reg_req   => { out => [ "gp", "flags", "none" ] },
	outs      => [ "res", "flags", "M" ],
	arity     => "variable",
Matthias Braun's avatar
Matthias Braun committed
212
213
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Matthias Braun's avatar
Matthias Braun committed
214
215
	emit      => "imul%M %AM",
	modified_flags => $status_flags,
216
},
217

218
imul_1op => {
219
	# Do not rematerialize this node
220
221
	# TODO: should mark this commutative as soon as the backend code
	#       can handle this special case
222
223
224
225
226
227
228
229
230
231
232
	# It produces 2 results and has strict constraints
	state     => "exc_pinned",
	reg_req   => { out => [ "rax", "flags", "none", "rdx" ] },
	outs      => [ "res_low", "flags", "M", "res_high" ],
	arity     => "variable",
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
	emit      => "imul%M %AM",
	modified_flags => $status_flags,
},

233
mul => {
234
235
236
237
238
239
240
241
242
243
244
245
	# Do not rematerialize this node
	# It produces 2 results and has strict constraints
	state     => "exc_pinned",
	reg_req   => { out => [ "rax", "flags", "none", "rdx" ] },
	outs      => [ "res_low", "flags", "M", "res_high" ],
	arity     => "variable",
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
	emit      => "mul%M %AM",
	modified_flags => $status_flags,
},

246
or => {
247
	irn_flags => [ "rematerializable", "commutative" ],
Matthias Braun's avatar
Matthias Braun committed
248
249
250
251
	state     => "exc_pinned",
	reg_req   => { out => [ "gp", "flags", "none" ] },
	outs      => [ "res", "flags", "M" ],
	arity     => "variable",
Matthias Braun's avatar
Matthias Braun committed
252
253
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Matthias Braun's avatar
Matthias Braun committed
254
255
	emit      => "or%M %AM",
	modified_flags => $status_flags,
256
257
},

258
shl => {
259
	irn_flags => [ "rematerializable" ],
260
261
	reg_req   => { out => [ "gp", "flags" ] },
	outs      => [ "res", "flags" ],
Matthias Braun's avatar
Matthias Braun committed
262
	arity     => "variable",
Matthias Braun's avatar
Matthias Braun committed
263
264
265
	attr_type => "amd64_shift_attr_t",
	attr      => "const amd64_shift_attr_t *attr_init",
	emit      => "shl%MS %SO",
266
267
268
	modified_flags => $status_flags
},

269
shr => {
270
	irn_flags => [ "rematerializable" ],
271
272
	reg_req   => { out => [ "gp", "flags" ] },
	outs      => [ "res", "flags" ],
Matthias Braun's avatar
Matthias Braun committed
273
	arity     => "variable",
Matthias Braun's avatar
Matthias Braun committed
274
275
276
	attr_type => "amd64_shift_attr_t",
	attr      => "const amd64_shift_attr_t *attr_init",
	emit      => "shr%MS %SO",
277
278
279
	modified_flags => $status_flags
},

280
sar => {
281
	irn_flags => [ "rematerializable" ],
282
283
	reg_req   => { out => [ "gp", "flags" ] },
	outs      => [ "res", "flags" ],
Matthias Braun's avatar
Matthias Braun committed
284
	arity     => "variable",
Matthias Braun's avatar
Matthias Braun committed
285
286
287
	attr_type => "amd64_shift_attr_t",
	attr      => "const amd64_shift_attr_t *attr_init",
	emit      => "sar%MS %SO",
288
289
290
	modified_flags => $status_flags
},

291
sub => {
Matthias Braun's avatar
Matthias Braun committed
292
293
294
295
296
297
298
	irn_flags => [ "rematerializable" ],
	state     => "exc_pinned",
	reg_req   => { out => [ "gp", "flags", "none" ] },
	outs      => [ "res", "flags", "M" ],
	arity     => "variable",
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
299
	emit      => "sub%M %AM",
300
	modified_flags => $status_flags,
301
},
302

303
sbb => {
304
	state     => "exc_pinned",
Tobias Rapp's avatar
Tobias Rapp committed
305
	reg_req   => { out => [ "gp", "flags", "none" ] },
306
	outs      => [ "res", "flags", "M" ],
Tobias Rapp's avatar
Tobias Rapp committed
307
	arity     => "variable",
308
309
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Tobias Rapp's avatar
Tobias Rapp committed
310
	emit      => "sbb%M %AM",
311
312
313
	modified_flags => $status_flags,
},

314
neg => {
315
	irn_flags => [ "rematerializable" ],
316
	reg_req   => { in => [ "gp" ], out => [ "in_r1", "flags" ] },
317
	ins       => [ "val" ],
318
	outs      => [ "res", "flags" ],
319
	attr_type => "amd64_addr_attr_t",
Matthias Braun's avatar
Matthias Braun committed
320
	attr      => "amd64_insn_mode_t insn_mode",
321
322
323
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_UNOP_REG;\n"
	            ."amd64_addr_t addr = { { NULL, 0 }, NO_INPUT, NO_INPUT, NO_INPUT, 0, AMD64_SEGMENT_DEFAULT };",
	emit      => "neg%M %AM",
324
325
	modified_flags => $status_flags
},
326

327
not => {
Christoph Mallon's avatar
Christoph Mallon committed
328
	irn_flags => [ "rematerializable" ],
Matthias Braun's avatar
Matthias Braun committed
329
	attr      => "amd64_insn_mode_t insn_mode",
Matthias Braun's avatar
Matthias Braun committed
330
	init_attr => "attr->insn_mode = insn_mode;",
331
	reg_req   => { in => [ "gp" ], out => [ "in_r1", "flags" ] },
Christoph Mallon's avatar
Christoph Mallon committed
332
	ins       => [ "val" ],
333
	outs      => [ "res", "flags" ],
334
335
336
337
	attr_type => "amd64_addr_attr_t",
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_UNOP_REG;\n"
	            ."amd64_addr_t addr = { { NULL, 0 }, NO_INPUT, NO_INPUT, NO_INPUT, 0, AMD64_SEGMENT_DEFAULT };",
	emit      => "not%M %AM",
Christoph Mallon's avatar
Christoph Mallon committed
338
339
340
	modified_flags => $status_flags
},

341
xor => {
342
	irn_flags => [ "rematerializable", "commutative" ],
Matthias Braun's avatar
Matthias Braun committed
343
344
345
346
	state     => "exc_pinned",
	reg_req   => { out => [ "gp", "flags", "none" ] },
	arity     => "variable",
	outs      => [ "res", "flags", "M" ],
Matthias Braun's avatar
Matthias Braun committed
347
348
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Matthias Braun's avatar
Matthias Braun committed
349
350
	emit      => "xor%M %AM",
	modified_flags => $status_flags,
351
352
},

353
xor_0 => {
Matthias Braun's avatar
Matthias Braun committed
354
355
	op_flags  => [ "constlike" ],
	irn_flags => [ "rematerializable" ],
356
357
	reg_req   => { out => [ "gp", "flags" ] },
	outs      => [ "res", "flags" ],
Matthias Braun's avatar
Matthias Braun committed
358
359
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_REG_REG;",
	emit      => "xorl %3D0, %3D0",
360
	modified_flags => $status_flags,
Matthias Braun's avatar
Matthias Braun committed
361
362
},

363
mov_imm => {
364
	op_flags  => [ "constlike" ],
365
	irn_flags => [ "rematerializable" ],
366
	reg_req   => { out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
367
368
369
370
	attr_type => "amd64_movimm_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, int64_t offset, ir_entity *entity",
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_IMM64;",
	emit      => 'mov%MM $%C, %D0',
371
	mode      => $mode_gp,
372
},
373

374
movs => {
375
	state     => "exc_pinned",
Matthias Braun's avatar
Matthias Braun committed
376
377
378
	reg_req   => { out => [ "gp", "none", "none" ] },
	outs      => [ "res", "unused", "M" ],
	arity     => "variable",
Matthias Braun's avatar
Matthias Braun committed
379
380
	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
381
382
383
	emit      => "movs%Mq %AM, %^D0",
},

384
mov_gp => {
Matthias Braun's avatar
Matthias Braun committed
385
386
387
388
	state     => "exc_pinned",
	reg_req   => { out => [ "gp", "none", "none" ] },
	outs      => [ "res", "unused", "M" ],
	arity     => "variable",
Matthias Braun's avatar
Matthias Braun committed
389
390
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
391
},
392

393
ijmp => {
394
395
	state     => "pinned",
	op_flags  => [ "cfopcode", "unknown_jump" ],
396
397
	reg_req   => { in => [ "gp" ], out => [ "none", "none", "none" ] },
	outs      => [ "X", "unused", "M" ],
398
399
	arity     => "variable",
	attr_type => "amd64_addr_attr_t",
400
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
401
	emit      => "jmp %*AM",
402
403
},

404
jmp => {
Matthias Braun's avatar
Matthias Braun committed
405
406
407
408
409
	state    => "pinned",
	op_flags => [ "cfopcode" ],
	reg_req  => { out => [ "none" ] },
	fixed    => "amd64_op_mode_t op_mode = AMD64_OP_IMM32;",
	mode     => "mode_X",
410
},
411

412
cmp => {
413
	irn_flags => [ "rematerializable" ],
414
	state     => "exc_pinned",
Matthias Braun's avatar
Matthias Braun committed
415
416
417
	reg_req   => { out => [ "none", "flags", "none" ] },
	arity     => "variable",
	outs      => [ "dummy", "flags", "M" ],
Matthias Braun's avatar
Matthias Braun committed
418
419
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Matthias Braun's avatar
Matthias Braun committed
420
	emit      => "cmp%M %AM",
421
	modified_flags => $status_flags,
422
},
423

424
lea => {
Matthias Braun's avatar
Matthias Braun committed
425
426
	irn_flags => [ "rematerializable" ],
	arity     => "variable",
427
428
	outs      => [ "res" ],
	reg_req   => { out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
429
430
431
	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
432
	emit      => "lea%M %A, %D0",
433
	mode      => $mode_gp,
Matthias Braun's avatar
Matthias Braun committed
434
435
},

436
jcc => {
437
	state     => "pinned",
438
	op_flags  => [ "cfopcode", "forking" ],
439
440
441
	reg_req   => { in  => [ "eflags" ], out => [ "none", "none" ] },
	ins       => [ "eflags" ],
	outs      => [ "false", "true" ],
442
	attr_type => "amd64_cc_attr_t",
Matthias Braun's avatar
Matthias Braun committed
443
444
	attr      => "x86_condition_code_t cc",
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
445
},
446

447
mov_store => {
448
	op_flags  => [ "uses_memory" ],
449
	state     => "exc_pinned",
Matthias Braun's avatar
Matthias Braun committed
450
451
	reg_req   => { out => [ "none" ] },
	arity     => "variable",
452
	outs      => [ "M" ],
Matthias Braun's avatar
Matthias Braun committed
453
454
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Matthias Braun's avatar
Matthias Braun committed
455
456
	mode      => "mode_M",
	emit      => "mov%M %S0, %A",
457
},
458

459
jmp_switch => {
Matthias Braun's avatar
Matthias Braun committed
460
461
462
463
464
465
466
	op_flags  => [ "cfopcode", "forking" ],
	state     => "pinned",
	reg_req   => { in => [ "gp" ], out => [ "none" ] },
	out_arity => "variable",
	attr_type => "amd64_switch_jmp_attr_t",
	attr      => "const ir_switch_table *table, ir_entity *table_entity",
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
467
468
},

469
call => {
470
471
472
	state     => "exc_pinned",
	arity     => "variable",
	out_arity => "variable",
Matthias Braun's avatar
Matthias Braun committed
473
474
475
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_op_mode_t op_mode, amd64_addr_t addr",
	fixed     => "amd64_insn_mode_t insn_mode = INSN_MODE_64;\n",
476
	emit      => "call %*AM",
477
	modified_flags => $all_flags,
478
479
},

480
start => {
481
	irn_flags => [ "schedule_first" ],
482
483
484
	state     => "pinned",
	out_arity => "variable",
	ins       => [],
Matthias Braun's avatar
Matthias Braun committed
485
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
486
	emit      => "",
487
488
},

489
ret => {
Matthias Braun's avatar
Matthias Braun committed
490
	state    => "pinned",
491
492
493
	op_flags => [ "cfopcode" ],
	arity    => "variable",
	reg_req  => { out => [ "none" ] },
Matthias Braun's avatar
Matthias Braun committed
494
	fixed    => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
495
	mode     => "mode_X",
496
	emit     => "ret",
497
498
},

499
500
# SSE

501
adds => {
502
	irn_flags  => [ "rematerializable", "commutative" ],
503
	state     => "exc_pinned",
504
505
	reg_req   => { out => [ "xmm", "none", "none" ] },
	outs      => [ "res", "none", "M" ],
506
507
508
509
510
511
	arity     => "variable",
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "adds%MX %AM",
},

512
divs => {
513
514
515
516
517
518
519
520
521
522
	irn_flags => [ "rematerializable" ],
	state     => "exc_pinned",
	reg_req   => { out => [ "xmm", "none", "none" ] },
	outs      => [ "res_div", "none", "M" ],
	arity     => "variable",
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "divs%MX %AM",
},

523
movs_xmm => {
524
525
526
527
528
529
530
531
532
	state     => "exc_pinned",
	reg_req   => { out => [ "xmm", "none", "none" ] },
	outs      => [ "res", "unused", "M" ],
	arity     => "variable",
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
	emit      => "movs%MX %AM, %D0",
},

533
muls => {
534
	irn_flags => [ "rematerializable", "commutative" ],
Tobias Rapp's avatar
Tobias Rapp committed
535
536
537
538
539
540
541
542
543
	state     => "exc_pinned",
	reg_req   => { out => [ "xmm", "none", "none" ] },
	outs      => [ "res", "none", "M" ],
	arity     => "variable",
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "muls%MX %AM",
},

544
movs_store_xmm => {
545
546
547
548
549
550
551
552
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
	reg_req   => { out => [ "none" ] },
	arity     => "variable",
	outs      => [ "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	mode      => "mode_M",
553
	emit      => "movs%MX %^S0, %A",
554
555
556
},


557
subs => {
558
559
	irn_flags => [ "rematerializable" ],
	state     => "exc_pinned",
560
561
	reg_req   => { out => [ "xmm", "none", "none" ] },
	outs      => [ "res", "none", "M" ],
562
563
564
	arity     => "variable",
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Tobias Rapp's avatar
Tobias Rapp committed
565
	emit      => "subs%MX %AM",
566
567
},

568
ucomis => {
Tobias Rapp's avatar
Tobias Rapp committed
569
570
571
572
573
574
575
576
577
578
579
	irn_flags => [ "rematerializable" ],
	state     => "exc_pinned",
	reg_req   => { out => [ "none", "flags", "none" ] },
	arity     => "variable",
	outs      => [ "dummy", "flags", "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "ucomis%MX %AM",
	modified_flags => $status_flags,
},

580
xorpd_0 => {
581
582
583
584
585
	op_flags  => [ "constlike" ],
	irn_flags => [ "rematerializable" ],
	reg_req   => { out => [ "xmm" ] },
	outs      => [ "res" ],
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_REG_REG;",
586
	emit      => "xorpd %^D0, %^D0",
587
588
589
	mode      => $mode_xmm,
},

590
xorp  => {
591
	irn_flags => [ "rematerializable", "commutative" ],
592
593
594
595
596
597
598
599
600
	state     => "exc_pinned",
	reg_req   => { out => [ "xmm", "none", "none" ] },
	arity     => "variable",
	outs      => [ "res", "none", "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "xorp%MX %AM",
},

601
602
# Conversion operations

603
cvtss2sd => {
604
605
606
607
608
609
610
611
612
	state     => "exc_pinned",
	reg_req   => { out => [ "xmm", "none", "none" ] },
	outs      => [ "res", "none", "M" ],
	arity     => "variable",
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
	emit      => "cvtss2sd %AM, %^D0",
},

613
cvtsd2ss => {
614
615
616
617
618
	state     => "exc_pinned",
	reg_req   => { out => [ "xmm", "none", "none" ] },
	outs      => [ "res", "none", "M" ],
	arity     => "variable",
	attr_type => "amd64_addr_attr_t",
619
620
	attr      => "amd64_op_mode_t op_mode, amd64_addr_t addr",
	fixed     => "amd64_insn_mode_t insn_mode = INSN_MODE_64;\n",
621
622
623
	emit      => "cvtsd2ss %AM, %^D0",
},

624
cvttsd2si => {
625
626
627
628
629
630
	state     => "exc_pinned",
	reg_req   => { out => [ "gp", "none", "none" ] },
	outs      => [ "res", "none", "M" ],
	arity     => "variable",
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
631
	emit      => "cvttsd2si %AM, %D0",
632
633
},

634
cvttss2si => {
635
636
637
638
639
640
	state     => "exc_pinned",
	reg_req   => { out => [ "gp", "none", "none" ] },
	outs      => [ "res", "none", "M" ],
	arity     => "variable",
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
641
	emit      => "cvttss2si %AM, %D0",
642
643
},

644
cvtsi2ss => {
645
646
647
648
649
650
651
652
653
	state     => "exc_pinned",
	reg_req   => { out => [ "xmm", "none", "none" ] },
	outs      => [ "res", "none", "M" ],
	arity     => "variable",
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
	emit      => "cvtsi2ss %AM, %^D0",
},

654
cvtsi2sd => {
655
656
657
658
659
660
661
662
663
	state     => "exc_pinned",
	reg_req   => { out => [ "xmm", "none", "none" ] },
	outs      => [ "res", "none", "M" ],
	arity     => "variable",
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
	emit      => "cvtsi2sd %AM, %^D0",
},

664
665
666
667
668
669
670
671
672
673
674
movq => {
	state     => "exc_pinned",
	arity     => "variable",
	outs      => [ "res", "none", "M" ],
	reg_req   => { out => [ "xmm", "none", "none" ] },
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_op_mode_t op_mode, amd64_addr_t addr",
	fixed     => "amd64_insn_mode_t insn_mode = INSN_MODE_64;\n",
	emit      => "movq %AM, %D0",
},

675
676
677
678
679
680
681
682
683
684
685
movdqa => {
	state     => "exc_pinned",
	arity     => "variable",
	outs      => [ "res", "none", "M" ],
	reg_req   => { out => [ "xmm", "none", "none" ] },
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_op_mode_t op_mode, amd64_addr_t addr",
	fixed     => "amd64_insn_mode_t insn_mode = INSN_MODE_128;\n",
	emit      => "movdqa %AM, %D0",
},

686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
movdqu => {
	state     => "exc_pinned",
	arity     => "variable",
	outs      => [ "res", "none", "M" ],
	reg_req   => { out => [ "xmm", "none", "none" ] },
	attr_type => "amd64_addr_attr_t",
	attr      => "amd64_op_mode_t op_mode, amd64_addr_t addr",
	fixed     => "amd64_insn_mode_t insn_mode = INSN_MODE_128;\n",
	emit      => "movdqu %AM, %D0",
},

movdqu_store => {
	op_flags  => [ "uses_memory" ],
	state     => "exc_pinned",
	reg_req   => { out => [ "none" ] },
	arity     => "variable",
	outs      => [ "M" ],
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	mode      => "mode_M",
	emit      => "movdqu %^S0, %A",
},

709
710
711
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
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
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 => {
	irn_flags => [ "rematerializable" ],
	state     => "exc_pinned",
	arity     => "variable",
	outs      => [ "res", "none", "M" ],
	reg_req   => { out => [ "xmm", "none", "none" ] },
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "punpckldq %AM",
},

subpd => {
	irn_flags => [ "rematerializable" ],
	state     => "exc_pinned",
	arity     => "variable",
	outs      => [ "res", "none", "M" ],
	reg_req   => { out => [ "xmm", "none", "none" ] },
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "subpd %AM",
},

haddpd => {
	irn_flags => [ "rematerializable" ],
	state     => "exc_pinned",
	arity     => "variable",
	outs      => [ "res", "none", "M" ],
	reg_req   => { out => [ "xmm", "none", "none" ] },
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "haddpd %AM",
},

766
);