Changeset 50553 in webkit for trunk/JavaScriptCore/assembler


Ignore:
Timestamp:
Nov 5, 2009, 12:28:02 AM (16 years ago)
Author:
[email protected]
Message:

Use ARMv7 specific encoding for immediate constants on ARMv7 target
https://bugs.webkit.org/show_bug.cgi?id=31060

Patch by Gabor Loki <[email protected]> on 2009-11-05
Reviewed by Gavin Barraclough.

  • assembler/ARMAssembler.cpp:

(JSC::ARMAssembler::getOp2): Use INVALID_IMM
(JSC::ARMAssembler::getImm): Use encodeComplexImm for complex immediate
(JSC::ARMAssembler::moveImm): Ditto.
(JSC::ARMAssembler::encodeComplexImm): Encode a constant by one or two
instructions or a PC relative load.

  • assembler/ARMAssembler.h: Use INVALID_IMM if a constant cannot be

encoded as an immediate constant.
(JSC::ARMAssembler::):
(JSC::ARMAssembler::movw_r): 16-bit immediate load
(JSC::ARMAssembler::movt_r): High halfword 16-bit immediate load
(JSC::ARMAssembler::getImm16Op2): Encode immediate constant for
movw_r and mowt_r

Location:
trunk/JavaScriptCore/assembler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/assembler/ARMAssembler.cpp

    r48525 r50553  
    119119        return OP2_IMM | (imm >> 24) | (rol << 8);
    120120
    121     return 0;
     121    return INVALID_IMM;
    122122}
    123123
     
    237237    // Do it by 1 instruction
    238238    tmp = getOp2(imm);
    239     if (tmp)
     239    if (tmp != INVALID_IMM)
    240240        return tmp;
    241241
    242242    tmp = getOp2(~imm);
    243     if (tmp) {
     243    if (tmp != INVALID_IMM) {
    244244        if (invert)
    245245            return tmp | OP2_INV_IMM;
     
    248248    }
    249249
    250     // Do it by 2 instruction
    251     if (genInt(tmpReg, imm, true))
    252         return tmpReg;
    253     if (genInt(tmpReg, ~imm, false))
    254         return tmpReg;
    255 
    256     ldr_imm(tmpReg, imm);
    257     return tmpReg;
     250    return encodeComplexImm(imm, tmpReg);
    258251}
    259252
     
    264257    // Do it by 1 instruction
    265258    tmp = getOp2(imm);
    266     if (tmp) {
     259    if (tmp != INVALID_IMM) {
    267260        mov_r(dest, tmp);
    268261        return;
     
    270263
    271264    tmp = getOp2(~imm);
    272     if (tmp) {
     265    if (tmp != INVALID_IMM) {
    273266        mvn_r(dest, tmp);
    274267        return;
    275268    }
    276269
     270    encodeComplexImm(imm, dest);
     271}
     272
     273ARMWord ARMAssembler::encodeComplexImm(ARMWord imm, int dest)
     274{
     275    ARMWord tmp;
     276
     277#if ARM_ARCH_VERSION >= 7
     278    tmp = getImm16Op2(imm);
     279    if (tmp != INVALID_IMM) {
     280        movw_r(dest, tmp);
     281        return dest;
     282    }
     283    movw_r(dest, getImm16Op2(imm & 0xffff));
     284    movt_r(dest, getImm16Op2(imm >> 16));
     285    return dest;
     286#else
    277287    // Do it by 2 instruction
    278288    if (genInt(dest, imm, true))
    279         return;
     289        return dest;
    280290    if (genInt(dest, ~imm, false))
    281         return;
     291        return dest;
    282292
    283293    ldr_imm(dest, imm);
     294    return dest;
     295#endif
    284296}
    285297
  • trunk/JavaScriptCore/assembler/ARMAssembler.h

    r48525 r50553  
    140140            BKPT = 0xe120070,
    141141#endif
     142#if ARM_ARCH_VERSION >= 7
     143            MOVW = 0x03000000,
     144            MOVT = 0x03400000,
     145#endif
    142146        };
    143147
     
    176180        };
    177181
     182        static const ARMWord INVALID_IMM = 0xf0000000;
     183
    178184        class JmpSrc {
    179185            friend class ARMAssembler;
     
    334340        }
    335341
     342#if ARM_ARCH_VERSION >= 7
     343        void movw_r(int rd, ARMWord op2, Condition cc = AL)
     344        {
     345            ASSERT((op2 | 0xf0fff) == 0xf0fff);
     346            m_buffer.putInt(static_cast<ARMWord>(cc) | MOVW | RD(rd) | op2);
     347        }
     348
     349        void movt_r(int rd, ARMWord op2, Condition cc = AL)
     350        {
     351            ASSERT((op2 | 0xf0fff) == 0xf0fff);
     352            m_buffer.putInt(static_cast<ARMWord>(cc) | MOVT | RD(rd) | op2);
     353        }
     354#endif
     355
    336356        void movs_r(int rd, ARMWord op2, Condition cc = AL)
    337357        {
     
    709729
    710730        static ARMWord getOp2(ARMWord imm);
     731
     732#if ARM_ARCH_VERSION >= 7
     733        static ARMWord getImm16Op2(ARMWord imm)
     734        {
     735            if (imm <= 0xffff)
     736                return (imm & 0xf000) << 4 | (imm & 0xfff);
     737            return INVALID_IMM;
     738        }
     739#endif
    711740        ARMWord getImm(ARMWord imm, int tmpReg, bool invert = false);
    712741        void moveImm(ARMWord imm, int dest);
     742        ARMWord encodeComplexImm(ARMWord imm, int dest);
    713743
    714744        // Memory load/store helpers
Note: See TracChangeset for help on using the changeset viewer.