Skip to content

Commit 5288921

Browse files
committed
[Hexagon] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 309746
1 parent d4e03d5 commit 5288921

25 files changed

+562
-398
lines changed

llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp

Lines changed: 47 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- HexagonAsmPrinter.cpp - Print machine instrs to Hexagon assembly --===//
1+
//===- HexagonAsmPrinter.cpp - Print machine instrs to Hexagon assembly ---===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -15,50 +15,50 @@
1515

1616
#include "HexagonAsmPrinter.h"
1717
#include "Hexagon.h"
18-
#include "HexagonMachineFunctionInfo.h"
18+
#include "HexagonInstrInfo.h"
19+
#include "HexagonRegisterInfo.h"
1920
#include "HexagonSubtarget.h"
20-
#include "HexagonTargetMachine.h"
2121
#include "MCTargetDesc/HexagonInstPrinter.h"
22+
#include "MCTargetDesc/HexagonMCExpr.h"
2223
#include "MCTargetDesc/HexagonMCInstrInfo.h"
23-
#include "MCTargetDesc/HexagonMCShuffler.h"
24+
#include "MCTargetDesc/HexagonMCTargetDesc.h"
2425
#include "llvm/ADT/StringExtras.h"
25-
#include "llvm/Analysis/ConstantFolding.h"
26+
#include "llvm/ADT/StringRef.h"
27+
#include "llvm/ADT/Twine.h"
2628
#include "llvm/BinaryFormat/ELF.h"
2729
#include "llvm/CodeGen/AsmPrinter.h"
28-
#include "llvm/CodeGen/MachineFunctionPass.h"
30+
#include "llvm/CodeGen/MachineBasicBlock.h"
31+
#include "llvm/CodeGen/MachineFunction.h"
2932
#include "llvm/CodeGen/MachineInstr.h"
30-
#include "llvm/CodeGen/MachineInstrBuilder.h"
31-
#include "llvm/CodeGen/MachineModuleInfo.h"
32-
#include "llvm/IR/Constants.h"
33-
#include "llvm/IR/DataLayout.h"
34-
#include "llvm/IR/DerivedTypes.h"
35-
#include "llvm/IR/Mangler.h"
36-
#include "llvm/IR/Module.h"
37-
#include "llvm/MC/MCAsmInfo.h"
33+
#include "llvm/CodeGen/MachineOperand.h"
3834
#include "llvm/MC/MCContext.h"
35+
#include "llvm/MC/MCDirectives.h"
3936
#include "llvm/MC/MCExpr.h"
4037
#include "llvm/MC/MCInst.h"
41-
#include "llvm/MC/MCSection.h"
38+
#include "llvm/MC/MCRegisterInfo.h"
4239
#include "llvm/MC/MCSectionELF.h"
4340
#include "llvm/MC/MCStreamer.h"
4441
#include "llvm/MC/MCSymbol.h"
42+
#include "llvm/Support/Casting.h"
4543
#include "llvm/Support/CommandLine.h"
46-
#include "llvm/Support/Debug.h"
47-
#include "llvm/Support/Format.h"
48-
#include "llvm/Support/MathExtras.h"
44+
#include "llvm/Support/ErrorHandling.h"
4945
#include "llvm/Support/TargetRegistry.h"
5046
#include "llvm/Support/raw_ostream.h"
51-
#include "llvm/Target/TargetInstrInfo.h"
52-
#include "llvm/Target/TargetLoweringObjectFile.h"
53-
#include "llvm/Target/TargetOptions.h"
5447
#include "llvm/Target/TargetRegisterInfo.h"
48+
#include "llvm/Target/TargetSubtargetInfo.h"
49+
#include <algorithm>
50+
#include <cassert>
51+
#include <cstdint>
52+
#include <string>
5553

5654
using namespace llvm;
5755

5856
namespace llvm {
59-
void HexagonLowerToMC(const MCInstrInfo &MCII, const MachineInstr *MI,
60-
MCInst &MCB, HexagonAsmPrinter &AP);
61-
}
57+
58+
void HexagonLowerToMC(const MCInstrInfo &MCII, const MachineInstr *MI,
59+
MCInst &MCB, HexagonAsmPrinter &AP);
60+
61+
} // end namespace llvm
6262

6363
#define DEBUG_TYPE "asm-printer"
6464

@@ -78,7 +78,7 @@ inline static unsigned getHexagonRegisterPair(unsigned Reg,
7878

7979
HexagonAsmPrinter::HexagonAsmPrinter(TargetMachine &TM,
8080
std::unique_ptr<MCStreamer> Streamer)
81-
: AsmPrinter(TM, std::move(Streamer)), Subtarget(nullptr) {}
81+
: AsmPrinter(TM, std::move(Streamer)) {}
8282

8383
void HexagonAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
8484
raw_ostream &O) {
@@ -106,24 +106,20 @@ void HexagonAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
106106
}
107107
}
108108

109-
//
110109
// isBlockOnlyReachableByFallthrough - We need to override this since the
111110
// default AsmPrinter does not print labels for any basic block that
112111
// is only reachable by a fall through. That works for all cases except
113112
// for the case in which the basic block is reachable by a fall through but
114113
// through an indirect from a jump table. In this case, the jump table
115114
// will contain a label not defined by AsmPrinter.
116-
//
117115
bool HexagonAsmPrinter::
118116
isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const {
119117
if (MBB->hasAddressTaken())
120118
return false;
121119
return AsmPrinter::isBlockOnlyReachableByFallthrough(MBB);
122120
}
123121

124-
125122
/// PrintAsmOperand - Print out an operand for an inline asm expression.
126-
///
127123
bool HexagonAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
128124
unsigned AsmVariant,
129125
const char *ExtraCode,
@@ -306,35 +302,30 @@ void HexagonAsmPrinter::HexagonProcessInstruction(MCInst &Inst,
306302
break;
307303
}
308304

309-
case Hexagon::A2_tfrf: {
305+
case Hexagon::A2_tfrf:
310306
Inst.setOpcode(Hexagon::A2_paddif);
311307
Inst.addOperand(MCOperand::createExpr(MCConstantExpr::create(0, OutContext)));
312308
break;
313-
}
314309

315-
case Hexagon::A2_tfrt: {
310+
case Hexagon::A2_tfrt:
316311
Inst.setOpcode(Hexagon::A2_paddit);
317312
Inst.addOperand(MCOperand::createExpr(MCConstantExpr::create(0, OutContext)));
318313
break;
319-
}
320314

321-
case Hexagon::A2_tfrfnew: {
315+
case Hexagon::A2_tfrfnew:
322316
Inst.setOpcode(Hexagon::A2_paddifnew);
323317
Inst.addOperand(MCOperand::createExpr(MCConstantExpr::create(0, OutContext)));
324318
break;
325-
}
326319

327-
case Hexagon::A2_tfrtnew: {
320+
case Hexagon::A2_tfrtnew:
328321
Inst.setOpcode(Hexagon::A2_padditnew);
329322
Inst.addOperand(MCOperand::createExpr(MCConstantExpr::create(0, OutContext)));
330323
break;
331-
}
332324

333-
case Hexagon::A2_zxtb: {
325+
case Hexagon::A2_zxtb:
334326
Inst.setOpcode(Hexagon::A2_andir);
335327
Inst.addOperand(MCOperand::createExpr(MCConstantExpr::create(255, OutContext)));
336328
break;
337-
}
338329

339330
// "$dst = CONST64(#$src1)",
340331
case Hexagon::CONST64:
@@ -386,7 +377,7 @@ void HexagonAsmPrinter::HexagonProcessInstruction(MCInst &Inst,
386377
// 3 register pairs.
387378
case Hexagon::M2_vrcmpys_acc_s1: {
388379
MCOperand &Rt = Inst.getOperand(3);
389-
assert (Rt.isReg() && "Expected register and none was found");
380+
assert(Rt.isReg() && "Expected register and none was found");
390381
unsigned Reg = RI->getEncodingValue(Rt.getReg());
391382
if (Reg & 1)
392383
MappedInst.setOpcode(Hexagon::M2_vrcmpys_acc_s1_h);
@@ -397,7 +388,7 @@ void HexagonAsmPrinter::HexagonProcessInstruction(MCInst &Inst,
397388
}
398389
case Hexagon::M2_vrcmpys_s1: {
399390
MCOperand &Rt = Inst.getOperand(2);
400-
assert (Rt.isReg() && "Expected register and none was found");
391+
assert(Rt.isReg() && "Expected register and none was found");
401392
unsigned Reg = RI->getEncodingValue(Rt.getReg());
402393
if (Reg & 1)
403394
MappedInst.setOpcode(Hexagon::M2_vrcmpys_s1_h);
@@ -409,7 +400,7 @@ void HexagonAsmPrinter::HexagonProcessInstruction(MCInst &Inst,
409400

410401
case Hexagon::M2_vrcmpys_s1rp: {
411402
MCOperand &Rt = Inst.getOperand(2);
412-
assert (Rt.isReg() && "Expected register and none was found");
403+
assert(Rt.isReg() && "Expected register and none was found");
413404
unsigned Reg = RI->getEncodingValue(Rt.getReg());
414405
if (Reg & 1)
415406
MappedInst.setOpcode(Hexagon::M2_vrcmpys_s1rp_h);
@@ -421,7 +412,7 @@ void HexagonAsmPrinter::HexagonProcessInstruction(MCInst &Inst,
421412

422413
case Hexagon::A4_boundscheck: {
423414
MCOperand &Rs = Inst.getOperand(1);
424-
assert (Rs.isReg() && "Expected register and none was found");
415+
assert(Rs.isReg() && "Expected register and none was found");
425416
unsigned Reg = RI->getEncodingValue(Rs.getReg());
426417
if (Reg & 1) // Odd mapped to raw:hi, regpair is rodd:odd-1, like r3:2
427418
MappedInst.setOpcode(Hexagon::A4_boundscheck_hi);
@@ -430,15 +421,17 @@ void HexagonAsmPrinter::HexagonProcessInstruction(MCInst &Inst,
430421
Rs.setReg(getHexagonRegisterPair(Rs.getReg(), RI));
431422
return;
432423
}
424+
433425
case Hexagon::PS_call_nr:
434426
Inst.setOpcode(Hexagon::J2_call);
435427
break;
428+
436429
case Hexagon::S5_asrhub_rnd_sat_goodsyntax: {
437430
MCOperand &MO = MappedInst.getOperand(2);
438431
int64_t Imm;
439432
MCExpr const *Expr = MO.getExpr();
440433
bool Success = Expr->evaluateAsAbsolute(Imm);
441-
assert (Success && "Expected immediate and none was found");
434+
assert(Success && "Expected immediate and none was found");
442435
(void)Success;
443436
MCInst TmpInst;
444437
if (Imm == 0) {
@@ -458,13 +451,14 @@ void HexagonAsmPrinter::HexagonProcessInstruction(MCInst &Inst,
458451
MappedInst = TmpInst;
459452
return;
460453
}
454+
461455
case Hexagon::S5_vasrhrnd_goodsyntax:
462456
case Hexagon::S2_asr_i_p_rnd_goodsyntax: {
463457
MCOperand &MO2 = MappedInst.getOperand(2);
464458
MCExpr const *Expr = MO2.getExpr();
465459
int64_t Imm;
466460
bool Success = Expr->evaluateAsAbsolute(Imm);
467-
assert (Success && "Expected immediate and none was found");
461+
assert(Success && "Expected immediate and none was found");
468462
(void)Success;
469463
MCInst TmpInst;
470464
if (Imm == 0) {
@@ -493,13 +487,14 @@ void HexagonAsmPrinter::HexagonProcessInstruction(MCInst &Inst,
493487
MappedInst = TmpInst;
494488
return;
495489
}
490+
496491
// if ("#u5==0") Assembler mapped to: "Rd=Rs"; else Rd=asr(Rs,#u5-1):rnd
497492
case Hexagon::S2_asr_i_r_rnd_goodsyntax: {
498493
MCOperand &MO = Inst.getOperand(2);
499494
MCExpr const *Expr = MO.getExpr();
500495
int64_t Imm;
501496
bool Success = Expr->evaluateAsAbsolute(Imm);
502-
assert (Success && "Expected immediate and none was found");
497+
assert(Success && "Expected immediate and none was found");
503498
(void)Success;
504499
MCInst TmpInst;
505500
if (Imm == 0) {
@@ -541,6 +536,7 @@ void HexagonAsmPrinter::HexagonProcessInstruction(MCInst &Inst,
541536
MappedInst = TmpInst;
542537
return;
543538
}
539+
544540
// Translate a "$Rdd = $Rss" to "$Rdd = combine($Rs, $Rt)"
545541
case Hexagon::A2_tfrp: {
546542
MCOperand &MO = MappedInst.getOperand(1);
@@ -566,6 +562,7 @@ void HexagonAsmPrinter::HexagonProcessInstruction(MCInst &Inst,
566562
: Hexagon::C2_ccombinewf);
567563
return;
568564
}
565+
569566
case Hexagon::A2_tfrptnew:
570567
case Hexagon::A2_tfrpfnew: {
571568
MCOperand &MO = MappedInst.getOperand(2);
@@ -598,7 +595,7 @@ void HexagonAsmPrinter::HexagonProcessInstruction(MCInst &Inst,
598595

599596
case Hexagon::A2_addsp: {
600597
MCOperand &Rt = Inst.getOperand(1);
601-
assert (Rt.isReg() && "Expected register and none was found");
598+
assert(Rt.isReg() && "Expected register and none was found");
602599
unsigned Reg = RI->getEncodingValue(Rt.getReg());
603600
if (Reg & 1)
604601
MappedInst.setOpcode(Hexagon::A2_addsph);
@@ -607,11 +604,12 @@ void HexagonAsmPrinter::HexagonProcessInstruction(MCInst &Inst,
607604
Rt.setReg(getHexagonRegisterPair(Rt.getReg(), RI));
608605
return;
609606
}
607+
610608
case Hexagon::V6_vd0:
611609
case Hexagon::V6_vd0_128B: {
612610
MCInst TmpInst;
613-
assert (Inst.getOperand(0).isReg() &&
614-
"Expected register and none was found");
611+
assert(Inst.getOperand(0).isReg() &&
612+
"Expected register and none was found");
615613

616614
TmpInst.setOpcode(Hexagon::V6_vxor);
617615
TmpInst.addOperand(Inst.getOperand(0));
@@ -799,10 +797,8 @@ void HexagonAsmPrinter::HexagonProcessInstruction(MCInst &Inst,
799797
}
800798
}
801799

802-
803800
/// printMachineInstruction -- Print out a single Hexagon MI in Darwin syntax to
804801
/// the current output stream.
805-
///
806802
void HexagonAsmPrinter::EmitInstruction(const MachineInstr *MI) {
807803
MCInst MCB = HexagonMCInstrInfo::createBundle();
808804
const MCInstrInfo &MCII = *Subtarget->getInstrInfo();

llvm/lib/Target/Hexagon/HexagonAsmPrinter.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- HexagonAsmPrinter.h - Print machine code to an Hexagon .s file ----===//
1+
//===- HexagonAsmPrinter.h - Print machine code to an Hexagon .s file -----===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -15,14 +15,20 @@
1515
#define LLVM_LIB_TARGET_HEXAGON_HEXAGONASMPRINTER_H
1616

1717
#include "Hexagon.h"
18-
#include "HexagonTargetMachine.h"
18+
#include "HexagonSubtarget.h"
1919
#include "llvm/CodeGen/AsmPrinter.h"
20-
#include "llvm/Support/Compiler.h"
21-
#include "llvm/Support/raw_ostream.h"
20+
#include "llvm/CodeGen/MachineFunction.h"
21+
#include <memory>
2222

2323
namespace llvm {
24+
25+
class MachineInstr;
26+
class MCInst;
27+
class raw_ostream;
28+
class TargetMachine;
29+
2430
class HexagonAsmPrinter : public AsmPrinter {
25-
const HexagonSubtarget *Subtarget;
31+
const HexagonSubtarget *Subtarget = nullptr;
2632

2733
public:
2834
explicit HexagonAsmPrinter(TargetMachine &TM,
@@ -45,7 +51,6 @@ namespace llvm {
4551
void HexagonProcessInstruction(MCInst &Inst,
4652
const MachineInstr &MBB);
4753

48-
4954
void printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O);
5055
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
5156
unsigned AsmVariant, const char *ExtraCode,
@@ -57,6 +62,6 @@ namespace llvm {
5762
static const char *getRegisterName(unsigned RegNo);
5863
};
5964

60-
} // end of llvm namespace
65+
} // end namespace llvm
6166

62-
#endif
67+
#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONASMPRINTER_H

llvm/lib/Target/Hexagon/HexagonMCInstLower.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,30 @@
1414

1515
#include "Hexagon.h"
1616
#include "HexagonAsmPrinter.h"
17-
#include "HexagonMachineFunctionInfo.h"
17+
#include "MCTargetDesc/HexagonMCExpr.h"
1818
#include "MCTargetDesc/HexagonMCInstrInfo.h"
19-
19+
#include "MCTargetDesc/HexagonMCTargetDesc.h"
20+
#include "llvm/ADT/APFloat.h"
21+
#include "llvm/ADT/APInt.h"
2022
#include "llvm/CodeGen/MachineBasicBlock.h"
23+
#include "llvm/CodeGen/MachineInstr.h"
24+
#include "llvm/CodeGen/MachineOperand.h"
2125
#include "llvm/IR/Constants.h"
22-
#include "llvm/IR/Mangler.h"
2326
#include "llvm/MC/MCContext.h"
2427
#include "llvm/MC/MCExpr.h"
2528
#include "llvm/MC/MCInst.h"
29+
#include "llvm/Support/ErrorHandling.h"
30+
#include "llvm/Support/raw_ostream.h"
31+
#include <cassert>
2632

2733
using namespace llvm;
2834

2935
namespace llvm {
30-
void HexagonLowerToMC(const MCInstrInfo &MCII, const MachineInstr *MI,
31-
MCInst &MCB, HexagonAsmPrinter &AP);
32-
}
36+
37+
void HexagonLowerToMC(const MCInstrInfo &MCII, const MachineInstr *MI,
38+
MCInst &MCB, HexagonAsmPrinter &AP);
39+
40+
} // end namespace llvm
3341

3442
static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol,
3543
HexagonAsmPrinter &Printer, bool MustExtend) {

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- HexagonTargetTransformInfo.cpp - Hexagon specific TTI pass --------===//
1+
//===- HexagonTargetTransformInfo.cpp - Hexagon specific TTI pass ---------===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -14,8 +14,13 @@
1414
//===----------------------------------------------------------------------===//
1515

1616
#include "HexagonTargetTransformInfo.h"
17+
#include "HexagonSubtarget.h"
18+
#include "llvm/Analysis/TargetTransformInfo.h"
19+
#include "llvm/IR/InstrTypes.h"
1720
#include "llvm/IR/Instructions.h"
18-
#include "llvm/Support/Debug.h"
21+
#include "llvm/IR/User.h"
22+
#include "llvm/Support/Casting.h"
23+
#include "llvm/Support/CommandLine.h"
1924

2025
using namespace llvm;
2126

0 commit comments

Comments
 (0)