Mercurial > hg > truffle
comparison graal/com.oracle.max.asmdis/src/com/sun/max/asm/gen/risc/field/SymbolicOperandField.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 | bc8527f3071c |
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.risc.field; | |
24 | |
25 import java.util.*; | |
26 | |
27 import com.sun.max.*; | |
28 import com.sun.max.asm.*; | |
29 import com.sun.max.asm.gen.*; | |
30 import com.sun.max.asm.gen.risc.*; | |
31 import com.sun.max.asm.gen.risc.bitRange.*; | |
32 import com.sun.max.util.*; | |
33 | |
34 /** | |
35 */ | |
36 public class SymbolicOperandField<Argument_Type extends SymbolicArgument> extends OperandField<Argument_Type> implements WrappableSpecification { | |
37 | |
38 private final Symbolizer<Argument_Type> symbolizer; | |
39 | |
40 public SymbolicOperandField(BitRange bitRange, Symbolizer<Argument_Type> symbolizer) { | |
41 super(bitRange); | |
42 assert symbolizer != null; | |
43 this.symbolizer = symbolizer; | |
44 } | |
45 | |
46 public static <Argument_Type extends SymbolicArgument> SymbolicOperandField<Argument_Type> createAscending(Symbolizer<Argument_Type> symbolizer, int... bits) { | |
47 final BitRange bitRange = BitRange.create(bits, BitRangeOrder.ASCENDING); | |
48 return new SymbolicOperandField<Argument_Type>(bitRange, symbolizer); | |
49 } | |
50 | |
51 public static <Argument_Type extends SymbolicArgument> SymbolicOperandField<Argument_Type> createDescending(String variableName, | |
52 final Symbolizer<Argument_Type> symbolizer, int... bits) { | |
53 final BitRange bitRange = BitRange.create(bits, BitRangeOrder.DESCENDING); | |
54 final SymbolicOperandField<Argument_Type> field = new SymbolicOperandField<Argument_Type>(bitRange, symbolizer); | |
55 if (variableName != null) { | |
56 field.setVariableName(variableName); | |
57 } | |
58 return field; | |
59 } | |
60 | |
61 public static <Argument_Type extends SymbolicArgument> SymbolicOperandField<Argument_Type> createDescending(Symbolizer<Argument_Type> symbolizer, int... bits) { | |
62 return createDescending(null, symbolizer, bits); | |
63 } | |
64 | |
65 public RiscConstant constant(Argument_Type argument) { | |
66 return new RiscConstant(new ConstantField(name(), bitRange()), argument); | |
67 } | |
68 | |
69 @Override | |
70 public Class type() { | |
71 return symbolizer.type(); | |
72 } | |
73 | |
74 public String valueString() { | |
75 if (boundTo() != null) { | |
76 return boundTo().valueString(); | |
77 } | |
78 return variableName() + ".value()"; | |
79 } | |
80 | |
81 public int assemble(Argument_Type argument) throws AssemblyException { | |
82 return bitRange().assembleUncheckedUnsignedInt(argument.value()); | |
83 } | |
84 | |
85 @Override | |
86 public Argument_Type disassemble(int instruction) { | |
87 return symbolizer.fromValue(extract(instruction)); | |
88 } | |
89 | |
90 @Override | |
91 public SymbolicOperandField<Argument_Type> setVariableName(String name) { | |
92 super.setVariableName(name); | |
93 return this; | |
94 } | |
95 | |
96 public ArgumentRange argumentRange() { | |
97 return null; | |
98 } | |
99 | |
100 public Iterable<? extends Argument> getLegalTestArguments() { | |
101 return symbolizer; | |
102 } | |
103 | |
104 public Iterable<? extends Argument> getIllegalTestArguments() { | |
105 return Collections.emptyList(); | |
106 } | |
107 | |
108 @Override | |
109 public SymbolicOperandField<Argument_Type> withExcludedExternalTestArguments(Argument... arguments) { | |
110 final Class<SymbolicOperandField<Argument_Type>> type = null; | |
111 return Utils.cast(type, super.withExcludedExternalTestArguments(arguments)); | |
112 } | |
113 | |
114 public TestArgumentExclusion excludeExternalTestArguments(Argument... arguments) { | |
115 return new TestArgumentExclusion(AssemblyTestComponent.EXTERNAL_ASSEMBLER, this, new HashSet<Argument>(Arrays.asList(arguments))); | |
116 } | |
117 | |
118 @Override | |
119 public SymbolicOperandField<Argument_Type> bindTo(Expression expression) { | |
120 final Class<SymbolicOperandField<Argument_Type>> type = null; | |
121 return Utils.cast(type, super.bindTo(expression)); | |
122 } | |
123 } |