Mercurial > hg > truffle
comparison graal/com.oracle.max.asmdis/src/com/sun/max/asm/dis/risc/RiscDisassembler.java @ 4142:bc8527f3071c
Adjust code base to new level of warnings.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 18 Dec 2011 05:24:06 +0100 |
parents | e233f5660da4 |
children |
comparison
equal
deleted
inserted
replaced
4141:04d21be7a24f | 4142:bc8527f3071c |
---|---|
22 */ | 22 */ |
23 package com.sun.max.asm.dis.risc; | 23 package com.sun.max.asm.dis.risc; |
24 | 24 |
25 import java.io.*; | 25 import java.io.*; |
26 import java.util.*; | 26 import java.util.*; |
27 import java.util.Arrays; | |
28 | 27 |
29 import com.sun.max.*; | 28 import com.sun.max.*; |
30 import com.sun.max.asm.*; | 29 import com.sun.max.asm.*; |
31 import com.sun.max.asm.dis.*; | 30 import com.sun.max.asm.dis.*; |
32 import com.sun.max.asm.gen.*; | 31 import com.sun.max.asm.gen.*; |
61 * | 60 * |
62 * @param instruction the encoded instruction | 61 * @param instruction the encoded instruction |
63 * @return the decoded arguments for each operand or null if at least one operand has | 62 * @return the decoded arguments for each operand or null if at least one operand has |
64 * an invalid value in the encoded instruction | 63 * an invalid value in the encoded instruction |
65 */ | 64 */ |
66 private List<Argument> disassemble(int instruction, RiscTemplate template) { | 65 private static List<Argument> disassemble(int instruction, RiscTemplate template) { |
67 final List<Argument> arguments = new ArrayList<Argument>(); | 66 final List<Argument> arguments = new ArrayList<>(); |
68 for (OperandField operandField : template.parameters()) { | 67 for (OperandField operandField : template.parameters()) { |
69 final Argument argument = operandField.disassemble(instruction); | 68 final Argument argument = operandField.disassemble(instruction); |
70 if (argument == null) { | 69 if (argument == null) { |
71 return null; | 70 return null; |
72 } | 71 } |
73 arguments.add(argument); | 72 arguments.add(argument); |
74 } | 73 } |
75 return arguments; | 74 return arguments; |
76 } | 75 } |
77 | 76 |
78 private boolean isLegalArgumentList(RiscTemplate template, List<Argument> arguments) { | 77 private static boolean isLegalArgumentList(RiscTemplate template, List<Argument> arguments) { |
79 final List<InstructionConstraint> constraints = template.instructionDescription().constraints(); | 78 final List<InstructionConstraint> constraints = template.instructionDescription().constraints(); |
80 for (InstructionConstraint constraint : constraints) { | 79 for (InstructionConstraint constraint : constraints) { |
81 if (!(constraint.check(template, arguments))) { | 80 if (!(constraint.check(template, arguments))) { |
82 return false; | 81 return false; |
83 } | 82 } |
98 protected abstract DisassembledInstruction createDisassembledInstruction(int position, byte[] bytes, RiscTemplate template, List<Argument> arguments); | 97 protected abstract DisassembledInstruction createDisassembledInstruction(int position, byte[] bytes, RiscTemplate template, List<Argument> arguments); |
99 | 98 |
100 @Override | 99 @Override |
101 public List<DisassembledObject> scanOne0(BufferedInputStream stream) throws IOException, AssemblyException { | 100 public List<DisassembledObject> scanOne0(BufferedInputStream stream) throws IOException, AssemblyException { |
102 final int instruction = endianness().readInt(stream); | 101 final int instruction = endianness().readInt(stream); |
103 final List<DisassembledObject> result = new LinkedList<DisassembledObject>(); | 102 final List<DisassembledObject> result = new LinkedList<>(); |
104 final byte[] instructionBytes = endianness().toBytes(instruction); | 103 final byte[] instructionBytes = endianness().toBytes(instruction); |
105 for (SpecificityGroup specificityGroup : assembly().specificityGroups()) { | 104 for (SpecificityGroup specificityGroup : assembly().specificityGroups()) { |
106 for (OpcodeMaskGroup opcodeMaskGroup : specificityGroup.opcodeMaskGroups()) { | 105 for (OpcodeMaskGroup opcodeMaskGroup : specificityGroup.opcodeMaskGroups()) { |
107 final int opcode = instruction & opcodeMaskGroup.mask(); | 106 final int opcode = instruction & opcodeMaskGroup.mask(); |
108 for (RiscTemplate template : opcodeMaskGroup.templatesFor(opcode)) { | 107 for (RiscTemplate template : opcodeMaskGroup.templatesFor(opcode)) { |
143 return result; | 142 return result; |
144 } | 143 } |
145 | 144 |
146 @Override | 145 @Override |
147 public List<DisassembledObject> scan0(BufferedInputStream stream) throws IOException, AssemblyException { | 146 public List<DisassembledObject> scan0(BufferedInputStream stream) throws IOException, AssemblyException { |
148 final List<DisassembledObject> result = new ArrayList<DisassembledObject>(); | 147 final List<DisassembledObject> result = new ArrayList<>(); |
149 try { | 148 try { |
150 while (true) { | 149 while (true) { |
151 | 150 |
152 scanInlineData(stream, result); | 151 scanInlineData(stream, result); |
153 | 152 |
176 | 175 |
177 protected RiscTemplate createInlineDataTemplate(InstructionDescription instructionDescription) { | 176 protected RiscTemplate createInlineDataTemplate(InstructionDescription instructionDescription) { |
178 return new RiscTemplate(instructionDescription); | 177 return new RiscTemplate(instructionDescription); |
179 } | 178 } |
180 | 179 |
180 @SuppressWarnings("unused") | |
181 private final ImmediateOperandField[] byteFields; | 181 private final ImmediateOperandField[] byteFields; |
182 | 182 |
183 private ImmediateOperandField createByteField(int index) { | 183 private ImmediateOperandField createByteField(int index) { |
184 if (assembly().bitRangeEndianness() == BitRangeOrder.ASCENDING) { | 184 if (assembly().bitRangeEndianness() == BitRangeOrder.ASCENDING) { |
185 final int firstBit = index * Bytes.WIDTH; | 185 final int firstBit = index * Bytes.WIDTH; |