OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // | 69 // |
70 struct Register { | 70 struct Register { |
71 static const int kMaxNumAllocatableRegisters = 6; | 71 static const int kMaxNumAllocatableRegisters = 6; |
72 static int NumAllocatableRegisters() { | 72 static int NumAllocatableRegisters() { |
73 return kMaxNumAllocatableRegisters; | 73 return kMaxNumAllocatableRegisters; |
74 } | 74 } |
75 static const int kNumRegisters = 8; | 75 static const int kNumRegisters = 8; |
76 | 76 |
77 static inline const char* AllocationIndexToString(int index); | 77 static inline const char* AllocationIndexToString(int index); |
78 | 78 |
| 79 static inline int ToAllocationIndex(Register reg); |
| 80 |
| 81 static inline Register FromAllocationIndex(int index); |
| 82 |
79 static Register from_code(int code) { | 83 static Register from_code(int code) { |
80 DCHECK(code >= 0); | 84 DCHECK(code >= 0); |
81 DCHECK(code < kNumRegisters); | 85 DCHECK(code < kNumRegisters); |
82 Register r = { code }; | 86 Register r = { code }; |
83 return r; | 87 return r; |
84 } | 88 } |
85 bool is_valid() const { return 0 <= code_ && code_ < kNumRegisters; } | 89 bool is_valid() const { return 0 <= code_ && code_ < kNumRegisters; } |
86 bool is(Register reg) const { return code_ == reg.code_; } | 90 bool is(Register reg) const { return code_ == reg.code_; } |
87 // eax, ebx, ecx and edx are byte registers, the rest are not. | 91 // eax, ebx, ecx and edx are byte registers, the rest are not. |
88 bool is_byte_register() const { return code_ <= 3; } | 92 bool is_byte_register() const { return code_ <= 3; } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 125 |
122 | 126 |
123 inline const char* Register::AllocationIndexToString(int index) { | 127 inline const char* Register::AllocationIndexToString(int index) { |
124 DCHECK(index >= 0 && index < kMaxNumAllocatableRegisters); | 128 DCHECK(index >= 0 && index < kMaxNumAllocatableRegisters); |
125 // This is the mapping of allocation indices to registers. | 129 // This is the mapping of allocation indices to registers. |
126 const char* const kNames[] = { "eax", "ecx", "edx", "ebx", "esi", "edi" }; | 130 const char* const kNames[] = { "eax", "ecx", "edx", "ebx", "esi", "edi" }; |
127 return kNames[index]; | 131 return kNames[index]; |
128 } | 132 } |
129 | 133 |
130 | 134 |
| 135 inline int Register::ToAllocationIndex(Register reg) { |
| 136 DCHECK(reg.is_valid() && !reg.is(esp) && !reg.is(ebp)); |
| 137 return (reg.code() >= 6) ? reg.code() - 2 : reg.code(); |
| 138 } |
| 139 |
| 140 |
| 141 inline Register Register::FromAllocationIndex(int index) { |
| 142 DCHECK(index >= 0 && index < kMaxNumAllocatableRegisters); |
| 143 return (index >= 4) ? from_code(index + 2) : from_code(index); |
| 144 } |
| 145 |
| 146 |
131 struct X87Register { | 147 struct X87Register { |
132 static const int kMaxNumAllocatableRegisters = 6; | 148 static const int kMaxNumAllocatableRegisters = 6; |
133 static const int kMaxNumRegisters = 8; | 149 static const int kMaxNumRegisters = 8; |
134 static int NumAllocatableRegisters() { | 150 static int NumAllocatableRegisters() { |
135 return kMaxNumAllocatableRegisters; | 151 return kMaxNumAllocatableRegisters; |
136 } | 152 } |
137 | 153 |
138 | 154 |
139 // TODO(turbofan): Proper support for float32. | 155 // TODO(turbofan): Proper support for float32. |
140 static int NumAllocatableAliasedRegisters() { | 156 static int NumAllocatableAliasedRegisters() { |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 private: | 1093 private: |
1078 Assembler* assembler_; | 1094 Assembler* assembler_; |
1079 #ifdef DEBUG | 1095 #ifdef DEBUG |
1080 int space_before_; | 1096 int space_before_; |
1081 #endif | 1097 #endif |
1082 }; | 1098 }; |
1083 | 1099 |
1084 } } // namespace v8::internal | 1100 } } // namespace v8::internal |
1085 | 1101 |
1086 #endif // V8_X87_ASSEMBLER_X87_H_ | 1102 #endif // V8_X87_ASSEMBLER_X87_H_ |
OLD | NEW |