Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: src/IceTargetLoweringARM32.cpp

Issue 1221643012: Subzero: Add -Wshadow to the build. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceTargetLowering.cpp ('k') | src/IceTargetLoweringMIPS32.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceTargetLoweringARM32.cpp - ARM32 lowering ------------===// 1 //===- subzero/src/IceTargetLoweringARM32.cpp - ARM32 lowering ------------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
11 /// This file implements the TargetLoweringARM32 class, which consists almost 11 /// This file implements the TargetLoweringARM32 class, which consists almost
12 /// entirely of the lowering sequence for each high-level instruction. 12 /// entirely of the lowering sequence for each high-level instruction.
13 /// 13 ///
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #include "IceTargetLoweringARM32.h" 16 #include "IceTargetLoweringARM32.h"
17 17
18 #include "IceCfg.h" 18 #include "IceCfg.h"
19 #include "IceCfgNode.h" 19 #include "IceCfgNode.h"
20 #include "IceClFlags.h" 20 #include "IceClFlags.h"
21 #include "IceDefs.h" 21 #include "IceDefs.h"
22 #include "IceELFObjectWriter.h" 22 #include "IceELFObjectWriter.h"
23 #include "IceGlobalInits.h" 23 #include "IceGlobalInits.h"
24 #include "IceInstARM32.h" 24 #include "IceInstARM32.h"
25 #include "IceLiveness.h" 25 #include "IceLiveness.h"
26 #include "IceOperand.h" 26 #include "IceOperand.h"
27 #include "IceRegistersARM32.h" 27 #include "IceRegistersARM32.h"
28 #include "IceTargetLoweringARM32.def" 28 #include "IceTargetLoweringARM32.def"
29 #include "IceUtils.h" 29 #include "IceUtils.h"
30
31 #pragma clang diagnostic push
32 #pragma clang diagnostic ignored "-Wunused-parameter"
33 #pragma clang diagnostic ignored "-Wshadow"
30 #include "llvm/Support/MathExtras.h" 34 #include "llvm/Support/MathExtras.h"
35 #pragma clang diagnostic pop
31 36
32 namespace Ice { 37 namespace Ice {
33 38
34 namespace { 39 namespace {
35 40
36 void UnimplementedError(const ClFlags &Flags) { 41 void UnimplementedError(const ClFlags &Flags) {
37 if (!Flags.getSkipUnimplemented()) { 42 if (!Flags.getSkipUnimplemented()) {
38 // Use llvm_unreachable instead of report_fatal_error, which gives better 43 // Use llvm_unreachable instead of report_fatal_error, which gives better
39 // stack traces. 44 // stack traces.
40 llvm_unreachable("Not yet implemented"); 45 llvm_unreachable("Not yet implemented");
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 // orr t_hi, t_hi, b.lo, lsr t_c2 1260 // orr t_hi, t_hi, b.lo, lsr t_c2
1256 // lsl t_lo, b.lo, c.lo 1261 // lsl t_lo, b.lo, c.lo
1257 // a.lo = t_lo 1262 // a.lo = t_lo
1258 // a.hi = t_hi 1263 // a.hi = t_hi
1259 // Can be strength-reduced for constant-shifts, but we don't do 1264 // Can be strength-reduced for constant-shifts, but we don't do
1260 // that for now. 1265 // that for now.
1261 // Given the sub/rsb T_C, C.lo, #32, one of the T_C will be negative. 1266 // Given the sub/rsb T_C, C.lo, #32, one of the T_C will be negative.
1262 // On ARM, shifts only take the lower 8 bits of the shift register, 1267 // On ARM, shifts only take the lower 8 bits of the shift register,
1263 // and saturate to the range 0-32, so the negative value will 1268 // and saturate to the range 0-32, so the negative value will
1264 // saturate to 32. 1269 // saturate to 32.
1265 Variable *T_Hi = makeReg(IceType_i32); 1270 T_Hi = makeReg(IceType_i32);
jvoung (off chromium) 2015/07/13 22:40:43 oops, T_Hi and T_Lo should already be temp regs fr
Jim Stichnoth 2015/07/13 23:01:04 Good point. I kept the assignment because 1174/11
1266 Variable *Src1RLo = legalizeToVar(Src1Lo); 1271 Variable *Src1RLo = legalizeToVar(Src1Lo);
1267 Constant *ThirtyTwo = Ctx->getConstantInt32(32); 1272 Constant *ThirtyTwo = Ctx->getConstantInt32(32);
1268 Variable *T_C1 = makeReg(IceType_i32); 1273 Variable *T_C1 = makeReg(IceType_i32);
1269 Variable *T_C2 = makeReg(IceType_i32); 1274 Variable *T_C2 = makeReg(IceType_i32);
1270 _sub(T_C1, Src1RLo, ThirtyTwo); 1275 _sub(T_C1, Src1RLo, ThirtyTwo);
1271 _lsl(T_Hi, Src0RHi, Src1RLo); 1276 _lsl(T_Hi, Src0RHi, Src1RLo);
1272 _orr(T_Hi, T_Hi, OperandARM32FlexReg::create(Func, IceType_i32, Src0RLo, 1277 _orr(T_Hi, T_Hi, OperandARM32FlexReg::create(Func, IceType_i32, Src0RLo,
1273 OperandARM32::LSL, T_C1)); 1278 OperandARM32::LSL, T_C1));
1274 _rsb(T_C2, Src1RLo, ThirtyTwo); 1279 _rsb(T_C2, Src1RLo, ThirtyTwo);
1275 _orr(T_Hi, T_Hi, OperandARM32FlexReg::create(Func, IceType_i32, Src0RLo, 1280 _orr(T_Hi, T_Hi, OperandARM32FlexReg::create(Func, IceType_i32, Src0RLo,
1276 OperandARM32::LSR, T_C2)); 1281 OperandARM32::LSR, T_C2));
1277 _mov(DestHi, T_Hi); 1282 _mov(DestHi, T_Hi);
1278 Variable *T_Lo = makeReg(IceType_i32); 1283 T_Lo = makeReg(IceType_i32);
1279 // _mov seems to sometimes have better register preferencing than lsl. 1284 // _mov seems to sometimes have better register preferencing than lsl.
1280 // Otherwise mov w/ lsl shifted register is a pseudo-instruction 1285 // Otherwise mov w/ lsl shifted register is a pseudo-instruction
1281 // that maps to lsl. 1286 // that maps to lsl.
1282 _mov(T_Lo, OperandARM32FlexReg::create(Func, IceType_i32, Src0RLo, 1287 _mov(T_Lo, OperandARM32FlexReg::create(Func, IceType_i32, Src0RLo,
1283 OperandARM32::LSL, Src1RLo)); 1288 OperandARM32::LSL, Src1RLo));
1284 _mov(DestLo, T_Lo); 1289 _mov(DestLo, T_Lo);
1285 return; 1290 return;
1286 } 1291 }
1287 case InstArithmetic::Lshr: 1292 case InstArithmetic::Lshr:
1288 // a=b>>c (unsigned) ==> 1293 // a=b>>c (unsigned) ==>
1289 // GCC 4.8 does: 1294 // GCC 4.8 does:
1290 // rsb t_c1, c.lo, #32 1295 // rsb t_c1, c.lo, #32
1291 // lsr t_lo, b.lo, c.lo 1296 // lsr t_lo, b.lo, c.lo
1292 // orr t_lo, t_lo, b.hi, lsl t_c1 1297 // orr t_lo, t_lo, b.hi, lsl t_c1
1293 // sub t_c2, c.lo, #32 1298 // sub t_c2, c.lo, #32
1294 // orr t_lo, t_lo, b.hi, lsr t_c2 1299 // orr t_lo, t_lo, b.hi, lsr t_c2
1295 // lsr t_hi, b.hi, c.lo 1300 // lsr t_hi, b.hi, c.lo
1296 // a.lo = t_lo 1301 // a.lo = t_lo
1297 // a.hi = t_hi 1302 // a.hi = t_hi
1298 case InstArithmetic::Ashr: { 1303 case InstArithmetic::Ashr: {
1299 // a=b>>c (signed) ==> ... 1304 // a=b>>c (signed) ==> ...
1300 // Ashr is similar, but the sub t_c2, c.lo, #32 should set flags, 1305 // Ashr is similar, but the sub t_c2, c.lo, #32 should set flags,
1301 // and the next orr should be conditioned on PLUS. The last two 1306 // and the next orr should be conditioned on PLUS. The last two
1302 // right shifts should also be arithmetic. 1307 // right shifts should also be arithmetic.
1303 bool IsAshr = Inst->getOp() == InstArithmetic::Ashr; 1308 bool IsAshr = Inst->getOp() == InstArithmetic::Ashr;
1304 Variable *T_Lo = makeReg(IceType_i32); 1309 T_Lo = makeReg(IceType_i32);
jvoung (off chromium) 2015/07/13 22:40:43 same
Jim Stichnoth 2015/07/13 23:01:04 Done.
1305 Variable *Src1RLo = legalizeToVar(Src1Lo); 1310 Variable *Src1RLo = legalizeToVar(Src1Lo);
1306 Constant *ThirtyTwo = Ctx->getConstantInt32(32); 1311 Constant *ThirtyTwo = Ctx->getConstantInt32(32);
1307 Variable *T_C1 = makeReg(IceType_i32); 1312 Variable *T_C1 = makeReg(IceType_i32);
1308 Variable *T_C2 = makeReg(IceType_i32); 1313 Variable *T_C2 = makeReg(IceType_i32);
1309 _rsb(T_C1, Src1RLo, ThirtyTwo); 1314 _rsb(T_C1, Src1RLo, ThirtyTwo);
1310 _lsr(T_Lo, Src0RLo, Src1RLo); 1315 _lsr(T_Lo, Src0RLo, Src1RLo);
1311 _orr(T_Lo, T_Lo, OperandARM32FlexReg::create(Func, IceType_i32, Src0RHi, 1316 _orr(T_Lo, T_Lo, OperandARM32FlexReg::create(Func, IceType_i32, Src0RHi,
1312 OperandARM32::LSL, T_C1)); 1317 OperandARM32::LSL, T_C1));
1313 OperandARM32::ShiftKind RShiftKind; 1318 OperandARM32::ShiftKind RShiftKind;
1314 CondARM32::Cond Pred; 1319 CondARM32::Cond Pred;
1315 if (IsAshr) { 1320 if (IsAshr) {
1316 _subs(T_C2, Src1RLo, ThirtyTwo); 1321 _subs(T_C2, Src1RLo, ThirtyTwo);
1317 RShiftKind = OperandARM32::ASR; 1322 RShiftKind = OperandARM32::ASR;
1318 Pred = CondARM32::PL; 1323 Pred = CondARM32::PL;
1319 } else { 1324 } else {
1320 _sub(T_C2, Src1RLo, ThirtyTwo); 1325 _sub(T_C2, Src1RLo, ThirtyTwo);
1321 RShiftKind = OperandARM32::LSR; 1326 RShiftKind = OperandARM32::LSR;
1322 Pred = CondARM32::AL; 1327 Pred = CondARM32::AL;
1323 } 1328 }
1324 _orr(T_Lo, T_Lo, OperandARM32FlexReg::create(Func, IceType_i32, Src0RHi, 1329 _orr(T_Lo, T_Lo, OperandARM32FlexReg::create(Func, IceType_i32, Src0RHi,
1325 RShiftKind, T_C2), 1330 RShiftKind, T_C2),
1326 Pred); 1331 Pred);
1327 _mov(DestLo, T_Lo); 1332 _mov(DestLo, T_Lo);
1328 Variable *T_Hi = makeReg(IceType_i32); 1333 T_Hi = makeReg(IceType_i32);
1329 _mov(T_Hi, OperandARM32FlexReg::create(Func, IceType_i32, Src0RHi, 1334 _mov(T_Hi, OperandARM32FlexReg::create(Func, IceType_i32, Src0RHi,
1330 RShiftKind, Src1RLo)); 1335 RShiftKind, Src1RLo));
1331 _mov(DestHi, T_Hi); 1336 _mov(DestHi, T_Hi);
1332 return; 1337 return;
1333 } 1338 }
1334 case InstArithmetic::Fadd: 1339 case InstArithmetic::Fadd:
1335 case InstArithmetic::Fsub: 1340 case InstArithmetic::Fsub:
1336 case InstArithmetic::Fmul: 1341 case InstArithmetic::Fmul:
1337 case InstArithmetic::Fdiv: 1342 case InstArithmetic::Fdiv:
1338 case InstArithmetic::Frem: 1343 case InstArithmetic::Frem:
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 Inst *NewCall = InstARM32Call::create(Func, ReturnReg, CallTarget); 1660 Inst *NewCall = InstARM32Call::create(Func, ReturnReg, CallTarget);
1656 Context.insert(NewCall); 1661 Context.insert(NewCall);
1657 if (ReturnRegHi) 1662 if (ReturnRegHi)
1658 Context.insert(InstFakeDef::create(Func, ReturnRegHi)); 1663 Context.insert(InstFakeDef::create(Func, ReturnRegHi));
1659 1664
1660 // Add the appropriate offset to SP. The call instruction takes care 1665 // Add the appropriate offset to SP. The call instruction takes care
1661 // of resetting the stack offset during emission. 1666 // of resetting the stack offset during emission.
1662 if (ParameterAreaSizeBytes) { 1667 if (ParameterAreaSizeBytes) {
1663 Operand *AddAmount = legalize(Ctx->getConstantInt32(ParameterAreaSizeBytes), 1668 Operand *AddAmount = legalize(Ctx->getConstantInt32(ParameterAreaSizeBytes),
1664 Legal_Reg | Legal_Flex); 1669 Legal_Reg | Legal_Flex);
1665 Variable *SP = getPhysicalRegister(RegARM32::Reg_sp);
1666 _add(SP, SP, AddAmount); 1670 _add(SP, SP, AddAmount);
1667 } 1671 }
1668 1672
1669 // Insert a register-kill pseudo instruction. 1673 // Insert a register-kill pseudo instruction.
1670 Context.insert(InstFakeKill::create(Func, NewCall)); 1674 Context.insert(InstFakeKill::create(Func, NewCall));
1671 1675
1672 // Generate a FakeUse to keep the call live if necessary. 1676 // Generate a FakeUse to keep the call live if necessary.
1673 if (Instr->hasSideEffects() && ReturnReg) { 1677 if (Instr->hasSideEffects() && ReturnReg) {
1674 Inst *FakeUse = InstFakeUse::create(Func, ReturnReg); 1678 Inst *FakeUse = InstFakeUse::create(Func, ReturnReg);
1675 Context.insert(FakeUse); 1679 Context.insert(FakeUse);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 Variable *T = makeReg(Dest->getType()); 1805 Variable *T = makeReg(Dest->getType());
1802 _uxt(T, Src0R); 1806 _uxt(T, Src0R);
1803 _mov(Dest, T); 1807 _mov(Dest, T);
1804 } 1808 }
1805 break; 1809 break;
1806 } 1810 }
1807 case InstCast::Trunc: { 1811 case InstCast::Trunc: {
1808 if (isVectorType(Dest->getType())) { 1812 if (isVectorType(Dest->getType())) {
1809 UnimplementedError(Func->getContext()->getFlags()); 1813 UnimplementedError(Func->getContext()->getFlags());
1810 } else { 1814 } else {
1811 Operand *Src0 = Inst->getSrc(0);
1812 if (Src0->getType() == IceType_i64) 1815 if (Src0->getType() == IceType_i64)
1813 Src0 = loOperand(Src0); 1816 Src0 = loOperand(Src0);
1814 Operand *Src0RF = legalize(Src0, Legal_Reg | Legal_Flex); 1817 Operand *Src0RF = legalize(Src0, Legal_Reg | Legal_Flex);
1815 // t1 = trunc Src0RF; Dest = t1 1818 // t1 = trunc Src0RF; Dest = t1
1816 Variable *T = makeReg(Dest->getType()); 1819 Variable *T = makeReg(Dest->getType());
1817 _mov(T, Src0RF); 1820 _mov(T, Src0RF);
1818 if (Dest->getType() == IceType_i1) 1821 if (Dest->getType() == IceType_i1)
1819 _and(T, T, Ctx->getConstantInt1(1)); 1822 _and(T, T, Ctx->getConstantInt1(1));
1820 _mov(Dest, T); 1823 _mov(Dest, T);
1821 } 1824 }
(...skipping 13 matching lines...) Expand all
1835 UnimplementedError(Func->getContext()->getFlags()); 1838 UnimplementedError(Func->getContext()->getFlags());
1836 break; 1839 break;
1837 case InstCast::Sitofp: 1840 case InstCast::Sitofp:
1838 UnimplementedError(Func->getContext()->getFlags()); 1841 UnimplementedError(Func->getContext()->getFlags());
1839 break; 1842 break;
1840 case InstCast::Uitofp: { 1843 case InstCast::Uitofp: {
1841 UnimplementedError(Func->getContext()->getFlags()); 1844 UnimplementedError(Func->getContext()->getFlags());
1842 break; 1845 break;
1843 } 1846 }
1844 case InstCast::Bitcast: { 1847 case InstCast::Bitcast: {
1845 Operand *Src0 = Inst->getSrc(0);
1846 if (Dest->getType() == Src0->getType()) { 1848 if (Dest->getType() == Src0->getType()) {
1847 InstAssign *Assign = InstAssign::create(Func, Dest, Src0); 1849 InstAssign *Assign = InstAssign::create(Func, Dest, Src0);
1848 lowerAssign(Assign); 1850 lowerAssign(Assign);
1849 return; 1851 return;
1850 } 1852 }
1851 UnimplementedError(Func->getContext()->getFlags()); 1853 UnimplementedError(Func->getContext()->getFlags());
1852 break; 1854 break;
1853 } 1855 }
1854 } 1856 }
1855 } 1857 }
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
2746 << ".eabi_attribute 68, 1 @ Tag_Virtualization_use\n"; 2748 << ".eabi_attribute 68, 1 @ Tag_Virtualization_use\n";
2747 if (CPUFeatures.hasFeature(TargetARM32Features::HWDivArm)) { 2749 if (CPUFeatures.hasFeature(TargetARM32Features::HWDivArm)) {
2748 Str << ".eabi_attribute 44, 2 @ Tag_DIV_use\n"; 2750 Str << ".eabi_attribute 44, 2 @ Tag_DIV_use\n";
2749 } 2751 }
2750 // Technically R9 is used for TLS with Sandboxing, and we reserve it. 2752 // Technically R9 is used for TLS with Sandboxing, and we reserve it.
2751 // However, for compatibility with current NaCl LLVM, don't claim that. 2753 // However, for compatibility with current NaCl LLVM, don't claim that.
2752 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n"; 2754 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n";
2753 } 2755 }
2754 2756
2755 } // end of namespace Ice 2757 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLowering.cpp ('k') | src/IceTargetLoweringMIPS32.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698