214 |
214 |
215 bool is8bit(int x) const { return -0x80 <= x && x < 0x80; } |
215 bool is8bit(int x) const { return -0x80 <= x && x < 0x80; } |
216 bool isByte(int x) const { return 0 <= x && x < 0x100; } |
216 bool isByte(int x) const { return 0 <= x && x < 0x100; } |
217 bool isShiftCount(int x) const { return 0 <= x && x < 32; } |
217 bool isShiftCount(int x) const { return 0 <= x && x < 32; } |
218 |
218 |
219 void emit_int8( int8_t x) { code_section()->emit_int8( x); } |
|
220 void emit_int16( int16_t x) { code_section()->emit_int16( x); } |
|
221 void emit_int32( int32_t x) { code_section()->emit_int32( x); } |
|
222 void emit_int64( int64_t x) { code_section()->emit_int64( x); } |
|
223 |
|
224 void emit_float( jfloat x) { code_section()->emit_float( x); } |
|
225 void emit_double( jdouble x) { code_section()->emit_double( x); } |
|
226 void emit_address(address x) { code_section()->emit_address(x); } |
|
227 |
|
228 void emit_byte(int x) { emit_int8 (x); } // deprecated |
|
229 void emit_long(jint x) { emit_int32(x); } // deprecated |
219 void emit_long(jint x) { emit_int32(x); } // deprecated |
230 |
220 |
231 // Instruction boundaries (required when emitting relocatable values). |
221 // Instruction boundaries (required when emitting relocatable values). |
232 class InstructionMark: public StackObj { |
222 class InstructionMark: public StackObj { |
233 private: |
223 private: |
281 // Creation |
271 // Creation |
282 AbstractAssembler(CodeBuffer* code); |
272 AbstractAssembler(CodeBuffer* code); |
283 |
273 |
284 // ensure buf contains all code (call this before using/copying the code) |
274 // ensure buf contains all code (call this before using/copying the code) |
285 void flush(); |
275 void flush(); |
|
276 |
|
277 void emit_int8( int8_t x) { code_section()->emit_int8( x); } |
|
278 void emit_int16( int16_t x) { code_section()->emit_int16( x); } |
|
279 void emit_int32( int32_t x) { code_section()->emit_int32( x); } |
|
280 void emit_int64( int64_t x) { code_section()->emit_int64( x); } |
|
281 |
|
282 void emit_float( jfloat x) { code_section()->emit_float( x); } |
|
283 void emit_double( jdouble x) { code_section()->emit_double( x); } |
|
284 void emit_address(address x) { code_section()->emit_address(x); } |
286 |
285 |
287 // min and max values for signed immediate ranges |
286 // min and max values for signed immediate ranges |
288 static int min_simm(int nbits) { return -(intptr_t(1) << (nbits - 1)) ; } |
287 static int min_simm(int nbits) { return -(intptr_t(1) << (nbits - 1)) ; } |
289 static int max_simm(int nbits) { return (intptr_t(1) << (nbits - 1)) - 1; } |
288 static int max_simm(int nbits) { return (intptr_t(1) << (nbits - 1)) - 1; } |
290 |
289 |
321 address inst_mark() const { return code_section()->mark(); } |
320 address inst_mark() const { return code_section()->mark(); } |
322 void set_inst_mark() { code_section()->set_mark(); } |
321 void set_inst_mark() { code_section()->set_mark(); } |
323 void clear_inst_mark() { code_section()->clear_mark(); } |
322 void clear_inst_mark() { code_section()->clear_mark(); } |
324 |
323 |
325 // Constants in code |
324 // Constants in code |
326 void a_byte(int x); |
|
327 void a_long(jint x); |
|
328 void relocate(RelocationHolder const& rspec, int format = 0) { |
325 void relocate(RelocationHolder const& rspec, int format = 0) { |
329 assert(!pd_check_instruction_mark() |
326 assert(!pd_check_instruction_mark() |
330 || inst_mark() == NULL || inst_mark() == code_section()->end(), |
327 || inst_mark() == NULL || inst_mark() == code_section()->end(), |
331 "call relocate() between instructions"); |
328 "call relocate() between instructions"); |
332 code_section()->relocate(code_section()->end(), rspec, format); |
329 code_section()->relocate(code_section()->end(), rspec, format); |