comparison graal/com.oracle.max.asmdis/src/com/sun/max/asm/gen/risc/RiscInstructionDescriptionCreator.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
44 @Override 44 @Override
45 protected RiscInstructionDescription createInstructionDescription(List<Object> specifications) { 45 protected RiscInstructionDescription createInstructionDescription(List<Object> specifications) {
46 return new RiscInstructionDescription(specifications); 46 return new RiscInstructionDescription(specifications);
47 } 47 }
48 48
49 private int firstStringIndex(List<Object> specifications) { 49 private static int firstStringIndex(List<Object> specifications) {
50 for (int i = 0; i < specifications.size(); i++) { 50 for (int i = 0; i < specifications.size(); i++) {
51 if (specifications.get(i) instanceof String) { 51 if (specifications.get(i) instanceof String) {
52 return i; 52 return i;
53 } 53 }
54 } 54 }
55 throw ProgramError.unexpected("template instruction description without name"); 55 throw ProgramError.unexpected("template instruction description without name");
56 } 56 }
57 57
58 private void setFirstString(List<Object> specifications, String value) { 58 private static void setFirstString(List<Object> specifications, String value) {
59 specifications.set(firstStringIndex(specifications), value); 59 specifications.set(firstStringIndex(specifications), value);
60 } 60 }
61 61
62 private void eliminateConstraintFor(Parameter parameter, List<Object> specifications) { 62 private static void eliminateConstraintFor(Parameter parameter, List<Object> specifications) {
63 for (final Iterator iterator = specifications.iterator(); iterator.hasNext();) { 63 for (final Iterator iterator = specifications.iterator(); iterator.hasNext();) {
64 final Object s = iterator.next(); 64 final Object s = iterator.next();
65 if (s instanceof InstructionConstraint) { 65 if (s instanceof InstructionConstraint) {
66 final InstructionConstraint constraint = (InstructionConstraint) s; 66 final InstructionConstraint constraint = (InstructionConstraint) s;
67 if (constraint.referencesParameter(parameter)) { 67 if (constraint.referencesParameter(parameter)) {
69 } 69 }
70 } 70 }
71 } 71 }
72 } 72 }
73 73
74 private boolean updateSpecifications(List<Object> specifications, Object pattern) { 74 private static boolean updateSpecifications(List<Object> specifications, Object pattern) {
75 for (int i = 0; i < specifications.size(); i++) { 75 for (int i = 0; i < specifications.size(); i++) {
76 final Object specification = specifications.get(i); 76 final Object specification = specifications.get(i);
77 if (specification.equals(pattern)) { 77 if (specification.equals(pattern)) {
78 specifications.set(i, pattern); 78 specifications.set(i, pattern);
79 return true; 79 return true;
100 } 100 }
101 return false; 101 return false;
102 } 102 }
103 103
104 private RiscInstructionDescription createSyntheticInstructionDescription(String name, RiscTemplate template, Object[] patterns) { 104 private RiscInstructionDescription createSyntheticInstructionDescription(String name, RiscTemplate template, Object[] patterns) {
105 final List<Object> specifications = new ArrayList<Object>(template.instructionDescription().specifications()); 105 final List<Object> specifications = new ArrayList<>(template.instructionDescription().specifications());
106 for (Object pattern : patterns) { 106 for (Object pattern : patterns) {
107 if (!updateSpecifications(specifications, pattern)) { 107 if (!updateSpecifications(specifications, pattern)) {
108 // InstructionDescription with the same name, but different specifications, skip it: 108 // InstructionDescription with the same name, but different specifications, skip it:
109 Trace.line(3, name + " not updated with " + pattern + " in " + specifications); 109 Trace.line(3, name + " not updated with " + pattern + " in " + specifications);
110 return null; 110 return null;
123 * @param templateName the internal name of the original instruction on which the synthetic instruction is based 123 * @param templateName the internal name of the original instruction on which the synthetic instruction is based
124 * @param patterns the replacements for one or more parameters of the original instruction 124 * @param patterns the replacements for one or more parameters of the original instruction
125 * @return the newly created instruction descriptions resulting from the substitution wrapped in a RiscInstructionDescriptionModifier 125 * @return the newly created instruction descriptions resulting from the substitution wrapped in a RiscInstructionDescriptionModifier
126 */ 126 */
127 protected RiscInstructionDescriptionModifier synthesize(String name, String templateName, Object... patterns) { 127 protected RiscInstructionDescriptionModifier synthesize(String name, String templateName, Object... patterns) {
128 final List<RiscInstructionDescription> instructionDescriptions = new ArrayList<RiscInstructionDescription>(); 128 final List<RiscInstructionDescription> instructionDescriptions = new ArrayList<>();
129 // Creating a new VariableSequence here prevents iterator comodification below: 129 // Creating a new VariableSequence here prevents iterator comodification below:
130 final List<? extends RiscTemplate> nameTemplates = templateCreator.nameToTemplates(templateName); 130 final List<? extends RiscTemplate> nameTemplates = templateCreator.nameToTemplates(templateName);
131 if (!nameTemplates.isEmpty()) { 131 if (!nameTemplates.isEmpty()) {
132 final List<RiscTemplate> templates = new ArrayList<RiscTemplate>(nameTemplates); 132 final List<RiscTemplate> templates = new ArrayList<>(nameTemplates);
133 assert !templates.isEmpty(); 133 assert !templates.isEmpty();
134 for (RiscTemplate template : templates) { 134 for (RiscTemplate template : templates) {
135 final RiscInstructionDescription instructionDescription = createSyntheticInstructionDescription(name, template, patterns); 135 final RiscInstructionDescription instructionDescription = createSyntheticInstructionDescription(name, template, patterns);
136 if (instructionDescription != null) { 136 if (instructionDescription != null) {
137 instructionDescriptions.add(instructionDescription); 137 instructionDescriptions.add(instructionDescription);