From 981e45424f52735b1c61ae0eac7e299ed313f8db Mon Sep 17 00:00:00 2001 From: Roland Levillain Date: Fri, 14 Nov 2014 11:47:14 +0000 Subject: Add support for int-to-char in the optimizing compiler. - Add support for the int-to-char Dex instruction in the optimizing compiler. - Implement the ARM and Thumb-2 UBFX instructions and add tests for them. - Generate x86, x86-64 and ARM (but not ARM64) code for byte to char, short to char, int to char (and char to char!) HTypeConversion nodes. - Add related tests to test/422-type-conversion. Change-Id: I5cd4c6d86f0f6a966c059715b98db35cc8f9de76 --- compiler/utils/arm/assembler_thumb2.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'compiler/utils/arm/assembler_thumb2.cc') diff --git a/compiler/utils/arm/assembler_thumb2.cc b/compiler/utils/arm/assembler_thumb2.cc index a309e187df..3ab9b2ba03 100644 --- a/compiler/utils/arm/assembler_thumb2.cc +++ b/compiler/utils/arm/assembler_thumb2.cc @@ -285,6 +285,27 @@ void Thumb2Assembler::sbfx(Register rd, Register rn, uint32_t lsb, uint32_t widt } +void Thumb2Assembler::ubfx(Register rd, Register rn, uint32_t lsb, uint32_t width, Condition cond) { + CheckCondition(cond); + CHECK_LE(lsb, 31U); + CHECK(1U <= width && width <= 32U) << width; + uint32_t widthminus1 = width - 1; + uint32_t imm2 = lsb & (B1 | B0); // Bits 0-1 of `lsb`. + uint32_t imm3 = (lsb & (B4 | B3 | B2)) >> 2; // Bits 2-4 of `lsb`. + + uint32_t op = 28U /* 0b11100 */; + int32_t encoding = B31 | B30 | B29 | B28 | B25 | + op << 20 | + static_cast(rn) << 16 | + imm3 << 12 | + static_cast(rd) << 8 | + imm2 << 6 | + widthminus1; + + Emit32(encoding); +} + + void Thumb2Assembler::ldr(Register rd, const Address& ad, Condition cond) { EmitLoadStore(cond, true, false, false, false, rd, ad); } -- cgit v1.2.3-59-g8ed1b