Mercurial > hg > truffle
comparison graal/com.oracle.max.asmdis/src/com/sun/max/asm/gen/cisc/x86/X86EnumerableParameter.java @ 3733:e233f5660da4
Added Java files from Maxine project.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 17 Dec 2011 19:59:18 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3732:3e2e8b8abdaf | 3733:e233f5660da4 |
---|---|
1 /* | |
2 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.sun.max.asm.gen.cisc.x86; | |
24 | |
25 import java.util.*; | |
26 | |
27 import com.sun.max.asm.*; | |
28 import com.sun.max.asm.gen.*; | |
29 import com.sun.max.program.*; | |
30 import com.sun.max.util.*; | |
31 | |
32 /** | |
33 */ | |
34 public class X86EnumerableParameter<EnumerableArgument_Type extends Enum<EnumerableArgument_Type> & EnumerableArgument<EnumerableArgument_Type>> extends X86Parameter implements EnumerableParameter { | |
35 | |
36 private final Enumerator<EnumerableArgument_Type> enumerator; | |
37 private final Argument exampleArgument; | |
38 | |
39 public X86EnumerableParameter(X86Operand.Designation designation, ParameterPlace place, Enumerator<EnumerableArgument_Type> enumerator) { | |
40 super(designation, place); | |
41 this.enumerator = enumerator; | |
42 final Iterator<EnumerableArgument_Type> it = enumerator.iterator(); | |
43 exampleArgument = it.hasNext() ? it.next().exampleValue() : null; | |
44 switch (place) { | |
45 case MOD_REG: | |
46 case MOD_REG_REXR: | |
47 case MOD_RM: | |
48 case MOD_RM_REXB: | |
49 setVariableName(designation.name().toLowerCase()); | |
50 break; | |
51 case SIB_SCALE: | |
52 setVariableName("scale"); | |
53 break; | |
54 case SIB_INDEX: | |
55 case SIB_INDEX_REXX: | |
56 setVariableName("index"); | |
57 break; | |
58 case SIB_BASE: | |
59 case SIB_BASE_REXB: | |
60 setVariableName("base"); | |
61 break; | |
62 case APPEND: | |
63 setVariableName(enumerator.type().getSimpleName().toLowerCase()); | |
64 break; | |
65 case OPCODE1: | |
66 case OPCODE1_REXB: | |
67 case OPCODE2_REXB: | |
68 setVariableName("register"); | |
69 break; | |
70 case OPCODE2: | |
71 setVariableName("st_i"); | |
72 break; | |
73 default: | |
74 throw ProgramError.unexpected(); | |
75 } | |
76 } | |
77 | |
78 public Enumerator<EnumerableArgument_Type> enumerator() { | |
79 return enumerator; | |
80 } | |
81 | |
82 public Class type() { | |
83 return enumerator.type(); | |
84 } | |
85 | |
86 public String valueString() { | |
87 return variableName() + ".value()"; | |
88 } | |
89 | |
90 public Iterable<EnumerableArgument_Type> getLegalTestArguments() { | |
91 return enumerator; | |
92 } | |
93 | |
94 public Iterable<? extends Argument> getIllegalTestArguments() { | |
95 return Collections.emptyList(); | |
96 } | |
97 | |
98 public Argument getExampleArgument() { | |
99 return exampleArgument; | |
100 } | |
101 | |
102 @Override | |
103 public String toString() { | |
104 return type().getSimpleName(); | |
105 } | |
106 | |
107 } |