amd64_spec.pl 22.1 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
72
73
74
	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;",
	amd64_binop_addr_attr_t =>
		"init_be_info(res, irn_flags_, in_reqs, n_res);\n"
		."\t*attr = *attr_init;",
75
	amd64_switch_jmp_attr_t =>
Matthias Braun's avatar
Matthias Braun committed
76
77
		"init_amd64_attributes(res, irn_flags_, in_reqs, n_res, op_mode);\n"
		."\tinit_amd64_switch_attributes(res, table, table_entity);",
78
	amd64_cc_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_cc_attributes(res, cc);",
81
	amd64_movimm_attr_t =>
Matthias Braun's avatar
Matthias Braun committed
82
83
84
85
86
		"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 =>
		"init_be_info(res, irn_flags_, in_reqs, n_res);\n"
		."\t*attr = *attr_init;\n",
87
88
89
);

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

102
103
104
105
106
107
108
109
110
111
PushRbp => {
	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",
},

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

Tobias Rapp's avatar
Tobias Rapp committed
124
125
126
127
128
129
130
131
132
133
134
135
SubSP => {
	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,
},

136
137
138
139
140
141
142
143
144
Leave => {
	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",
},

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

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

168
169
},

Matthias Braun's avatar
Matthias Braun committed
170
Div => {
171
	state     => "pinned",
Matthias Braun's avatar
Matthias Braun committed
172
173
174
175
	reg_req   => { out => [ "rax", "flags", "none", "rdx" ] },
	arity     => "variable",
	outs      => [ "res_div", "flags", "M", "res_mod" ],
	attr_type => "amd64_addr_attr_t",
176
177
178
	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",
179
	emit      => "div%M %AM",
180
	modified_flags => $status_flags,
Matthias Braun's avatar
Matthias Braun committed
181
182
183
},

IDiv => {
184
	state     => "pinned",
Matthias Braun's avatar
Matthias Braun committed
185
186
187
188
	reg_req   => { out => [ "rax", "flags", "none", "rdx" ] },
	arity     => "variable",
	outs      => [ "res_div", "flags", "M", "res_mod" ],
	attr_type => "amd64_addr_attr_t",
189
190
191
	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
192
	emit      => "idiv%M %AM",
193
	modified_flags => $status_flags,
Matthias Braun's avatar
Matthias Braun committed
194
195
},

196
IMul => {
197
	irn_flags => [ "rematerializable", "commutative" ],
Robin Redeker's avatar
Robin Redeker committed
198
	state     => "exc_pinned",
Matthias Braun's avatar
Matthias Braun committed
199
200
201
	reg_req   => { out => [ "gp", "flags", "none" ] },
	outs      => [ "res", "flags", "M" ],
	arity     => "variable",
Matthias Braun's avatar
Matthias Braun committed
202
203
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Matthias Braun's avatar
Matthias Braun committed
204
205
	emit      => "imul%M %AM",
	modified_flags => $status_flags,
206
},
207

208
209
IMul1Op => {
	# Do not rematerialize this node
210
211
	# TODO: should mark this commutative as soon as the backend code
	#       can handle this special case
212
213
214
215
216
217
218
219
220
221
222
	# 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,
},

223
224
225
226
227
228
229
230
231
232
233
234
235
Mul => {
	# 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,
},

236
Or => {
237
	irn_flags => [ "rematerializable", "commutative" ],
Matthias Braun's avatar
Matthias Braun committed
238
239
240
241
	state     => "exc_pinned",
	reg_req   => { out => [ "gp", "flags", "none" ] },
	outs      => [ "res", "flags", "M" ],
	arity     => "variable",
Matthias Braun's avatar
Matthias Braun committed
242
243
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Matthias Braun's avatar
Matthias Braun committed
244
245
	emit      => "or%M %AM",
	modified_flags => $status_flags,
246
247
248
249
},

Shl => {
	irn_flags => [ "rematerializable" ],
250
251
	reg_req   => { out => [ "gp", "flags" ] },
	outs      => [ "res", "flags" ],
Matthias Braun's avatar
Matthias Braun committed
252
	arity     => "variable",
Matthias Braun's avatar
Matthias Braun committed
253
254
255
	attr_type => "amd64_shift_attr_t",
	attr      => "const amd64_shift_attr_t *attr_init",
	emit      => "shl%MS %SO",
256
257
258
259
260
	modified_flags => $status_flags
},

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

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

281
Sub => {
Matthias Braun's avatar
Matthias Braun committed
282
283
284
285
286
287
288
	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",
289
	emit      => "sub%M %AM",
290
	modified_flags => $status_flags,
291
},
292

293
294
Sbb => {
	state     => "exc_pinned",
Tobias Rapp's avatar
Tobias Rapp committed
295
	reg_req   => { out => [ "gp", "flags", "none" ] },
296
	outs      => [ "res", "flags", "M" ],
Tobias Rapp's avatar
Tobias Rapp committed
297
	arity     => "variable",
298
299
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Tobias Rapp's avatar
Tobias Rapp committed
300
	emit      => "sbb%M %AM",
301
302
303
	modified_flags => $status_flags,
},

304
Neg => {
305
	irn_flags => [ "rematerializable" ],
306
	reg_req   => { in => [ "gp" ], out => [ "in_r1", "flags" ] },
307
	ins       => [ "val" ],
308
	outs      => [ "res", "flags" ],
309
	attr_type => "amd64_addr_attr_t",
Matthias Braun's avatar
Matthias Braun committed
310
	attr      => "amd64_insn_mode_t insn_mode",
311
312
313
	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",
314
315
	modified_flags => $status_flags
},
316

Christoph Mallon's avatar
Christoph Mallon committed
317
318
Not => {
	irn_flags => [ "rematerializable" ],
Matthias Braun's avatar
Matthias Braun committed
319
	attr      => "amd64_insn_mode_t insn_mode",
Matthias Braun's avatar
Matthias Braun committed
320
	init_attr => "attr->insn_mode = insn_mode;",
321
	reg_req   => { in => [ "gp" ], out => [ "in_r1", "flags" ] },
Christoph Mallon's avatar
Christoph Mallon committed
322
	ins       => [ "val" ],
323
	outs      => [ "res", "flags" ],
324
325
326
327
	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
328
329
330
	modified_flags => $status_flags
},

331
Xor => {
332
	irn_flags => [ "rematerializable", "commutative" ],
Matthias Braun's avatar
Matthias Braun committed
333
334
335
336
	state     => "exc_pinned",
	reg_req   => { out => [ "gp", "flags", "none" ] },
	arity     => "variable",
	outs      => [ "res", "flags", "M" ],
Matthias Braun's avatar
Matthias Braun committed
337
338
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Matthias Braun's avatar
Matthias Braun committed
339
340
	emit      => "xor%M %AM",
	modified_flags => $status_flags,
341
342
},

Matthias Braun's avatar
Matthias Braun committed
343
Xor0 => {
Matthias Braun's avatar
Matthias Braun committed
344
345
	op_flags  => [ "constlike" ],
	irn_flags => [ "rematerializable" ],
346
347
	reg_req   => { out => [ "gp", "flags" ] },
	outs      => [ "res", "flags" ],
Matthias Braun's avatar
Matthias Braun committed
348
349
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_REG_REG;",
	emit      => "xorl %3D0, %3D0",
350
	modified_flags => $status_flags,
Matthias Braun's avatar
Matthias Braun committed
351
352
},

Matthias Braun's avatar
Matthias Braun committed
353
MovImm => {
354
	op_flags  => [ "constlike" ],
355
	irn_flags => [ "rematerializable" ],
356
	reg_req   => { out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
357
358
359
360
	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',
361
	mode      => $mode_gp,
362
},
363

Matthias Braun's avatar
Matthias Braun committed
364
Movs => {
365
	state     => "exc_pinned",
Matthias Braun's avatar
Matthias Braun committed
366
367
368
	reg_req   => { out => [ "gp", "none", "none" ] },
	outs      => [ "res", "unused", "M" ],
	arity     => "variable",
Matthias Braun's avatar
Matthias Braun committed
369
370
	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
371
372
373
	emit      => "movs%Mq %AM, %^D0",
},

Matthias Braun's avatar
Matthias Braun committed
374
Mov => {
Matthias Braun's avatar
Matthias Braun committed
375
376
377
378
	state     => "exc_pinned",
	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",
381
},
382

383
384
385
IJmp => {
	state     => "pinned",
	op_flags  => [ "cfopcode", "unknown_jump" ],
386
387
	reg_req   => { in => [ "gp" ], out => [ "none", "none", "none" ] },
	outs      => [ "X", "unused", "M" ],
388
389
	arity     => "variable",
	attr_type => "amd64_addr_attr_t",
390
	attr      => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
391
	emit      => "jmp %*AM",
392
393
},

394
Jmp => {
Matthias Braun's avatar
Matthias Braun committed
395
396
397
398
399
	state    => "pinned",
	op_flags => [ "cfopcode" ],
	reg_req  => { out => [ "none" ] },
	fixed    => "amd64_op_mode_t op_mode = AMD64_OP_IMM32;",
	mode     => "mode_X",
400
},
401

402
Cmp => {
403
	irn_flags => [ "rematerializable" ],
404
	state     => "exc_pinned",
Matthias Braun's avatar
Matthias Braun committed
405
406
407
	reg_req   => { out => [ "none", "flags", "none" ] },
	arity     => "variable",
	outs      => [ "dummy", "flags", "M" ],
Matthias Braun's avatar
Matthias Braun committed
408
409
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Matthias Braun's avatar
Matthias Braun committed
410
	emit      => "cmp%M %AM",
411
	modified_flags => $status_flags,
412
},
413

Matthias Braun's avatar
Matthias Braun committed
414
415
416
Lea => {
	irn_flags => [ "rematerializable" ],
	arity     => "variable",
417
418
	outs      => [ "res" ],
	reg_req   => { out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
419
420
421
	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
422
	emit      => "lea%M %A, %D0",
423
	mode      => $mode_gp,
Matthias Braun's avatar
Matthias Braun committed
424
425
},

426
427
Jcc => {
	state     => "pinned",
428
	op_flags  => [ "cfopcode", "forking" ],
429
430
431
	reg_req   => { in  => [ "eflags" ], out => [ "none", "none" ] },
	ins       => [ "eflags" ],
	outs      => [ "false", "true" ],
432
	attr_type => "amd64_cc_attr_t",
Matthias Braun's avatar
Matthias Braun committed
433
434
	attr      => "x86_condition_code_t cc",
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
435
},
436

437
Store => {
438
	op_flags  => [ "uses_memory" ],
439
	state     => "exc_pinned",
Matthias Braun's avatar
Matthias Braun committed
440
441
	reg_req   => { out => [ "none" ] },
	arity     => "variable",
442
	outs      => [ "M" ],
Matthias Braun's avatar
Matthias Braun committed
443
444
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
Matthias Braun's avatar
Matthias Braun committed
445
446
	mode      => "mode_M",
	emit      => "mov%M %S0, %A",
447
},
448
449

SwitchJmp => {
Matthias Braun's avatar
Matthias Braun committed
450
451
452
453
454
455
456
	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",
457
458
},

459
460
461
462
Call => {
	state     => "exc_pinned",
	arity     => "variable",
	out_arity => "variable",
Matthias Braun's avatar
Matthias Braun committed
463
464
465
	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",
466
	emit      => "call %*AM",
467
	modified_flags => $all_flags,
468
469
470
},

Start => {
471
	irn_flags => [ "schedule_first" ],
472
473
474
	state     => "pinned",
	out_arity => "variable",
	ins       => [],
Matthias Braun's avatar
Matthias Braun committed
475
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
476
	emit      => "",
477
478
479
},

Return => {
Matthias Braun's avatar
Matthias Braun committed
480
	state    => "pinned",
481
482
483
	op_flags => [ "cfopcode" ],
	arity    => "variable",
	reg_req  => { out => [ "none" ] },
Matthias Braun's avatar
Matthias Braun committed
484
	fixed    => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
485
	mode     => "mode_X",
486
	emit     => "ret",
487
488
},

489
490
# SSE

491
xAdds => {
492
	irn_flags  => [ "rematerializable", "commutative" ],
493
	state     => "exc_pinned",
494
495
	reg_req   => { out => [ "xmm", "none", "none" ] },
	outs      => [ "res", "none", "M" ],
496
497
498
499
500
501
	arity     => "variable",
	attr_type => "amd64_binop_addr_attr_t",
	attr      => "const amd64_binop_addr_attr_t *attr_init",
	emit      => "adds%MX %AM",
},

502
503
504
505
506
507
508
509
510
511
512
xDivs => {
	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",
},

513
514
515
516
517
518
519
520
521
522
xMovs => {
	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",
},

Tobias Rapp's avatar
Tobias Rapp committed
523
xMuls => {
524
	irn_flags => [ "rematerializable", "commutative" ],
Tobias Rapp's avatar
Tobias Rapp committed
525
526
527
528
529
530
531
532
533
	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",
},

534
xStores => {
535
536
537
538
539
540
541
542
	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",
543
	emit      => "movs%MX %^S0, %A",
544
545
546
},


547
xSubs => {
548
549
	irn_flags => [ "rematerializable" ],
	state     => "exc_pinned",
550
551
	reg_req   => { out => [ "xmm", "none", "none" ] },
	outs      => [ "res", "none", "M" ],
552
553
554
	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
555
	emit      => "subs%MX %AM",
556
557
},

Tobias Rapp's avatar
Tobias Rapp committed
558
559
560
561
562
563
564
565
566
567
568
569
xUcomis => {
	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,
},

570
xXorp0 => {
571
572
573
574
575
	op_flags  => [ "constlike" ],
	irn_flags => [ "rematerializable" ],
	reg_req   => { out => [ "xmm" ] },
	outs      => [ "res" ],
	fixed     => "amd64_op_mode_t op_mode = AMD64_OP_REG_REG;",
576
	emit      => "xorpd %^D0, %^D0",
577
578
579
	mode      => $mode_xmm,
},

580
xXorp  => {
581
	irn_flags => [ "rematerializable", "commutative" ],
582
583
584
585
586
587
588
589
590
	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",
},

591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
# Conversion operations

CvtSS2SD => {
	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",
},

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

CvtSD2SI => {
	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",
621
	emit      => "cvttsd2si %AM, %D0",
622
623
624
625
626
627
628
629
630
},

CvtSS2SI => {
	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      => "cvttss2si %AM, %D0",
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
},

CvtSI2SS => {
	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",
},

CvtSI2SD => {
	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",
},

654
655
656
657
658
659
660
661
662
663
664
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",
},

665
666
667
668
669
670
671
672
673
674
675
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",
},

676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
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",
},

699
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
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
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",
},

756
);