[XCore] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292988 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eugene Zelenko 2017-01-24 23:02:48 +00:00
parent e8e3365d52
commit adb0ce8f9c
5 changed files with 53 additions and 42 deletions

View File

@ -11,15 +11,19 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "XCoreMCTargetDesc.h"
#include "InstPrinter/XCoreInstPrinter.h" #include "InstPrinter/XCoreInstPrinter.h"
#include "XCoreMCAsmInfo.h" #include "MCTargetDesc/XCoreMCAsmInfo.h"
#include "MCTargetDesc/XCoreMCTargetDesc.h"
#include "XCoreTargetStreamer.h" #include "XCoreTargetStreamer.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/FormattedStream.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/TargetRegistry.h" #include "llvm/Support/TargetRegistry.h"
using namespace llvm; using namespace llvm;
@ -79,20 +83,25 @@ static MCInstPrinter *createXCoreMCInstPrinter(const Triple &T,
} }
XCoreTargetStreamer::XCoreTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {} XCoreTargetStreamer::XCoreTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
XCoreTargetStreamer::~XCoreTargetStreamer() {}
XCoreTargetStreamer::~XCoreTargetStreamer() = default;
namespace { namespace {
class XCoreTargetAsmStreamer : public XCoreTargetStreamer { class XCoreTargetAsmStreamer : public XCoreTargetStreamer {
formatted_raw_ostream &OS; formatted_raw_ostream &OS;
public: public:
XCoreTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS); XCoreTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
void emitCCTopData(StringRef Name) override; void emitCCTopData(StringRef Name) override;
void emitCCTopFunction(StringRef Name) override; void emitCCTopFunction(StringRef Name) override;
void emitCCBottomData(StringRef Name) override; void emitCCBottomData(StringRef Name) override;
void emitCCBottomFunction(StringRef Name) override; void emitCCBottomFunction(StringRef Name) override;
}; };
} // end anonymous namespace
XCoreTargetAsmStreamer::XCoreTargetAsmStreamer(MCStreamer &S, XCoreTargetAsmStreamer::XCoreTargetAsmStreamer(MCStreamer &S,
formatted_raw_ostream &OS) formatted_raw_ostream &OS)
: XCoreTargetStreamer(S), OS(OS) {} : XCoreTargetStreamer(S), OS(OS) {}
@ -112,7 +121,6 @@ void XCoreTargetAsmStreamer::emitCCBottomData(StringRef Name) {
void XCoreTargetAsmStreamer::emitCCBottomFunction(StringRef Name) { void XCoreTargetAsmStreamer::emitCCBottomFunction(StringRef Name) {
OS << "\t.cc_bottom " << Name << ".function\n"; OS << "\t.cc_bottom " << Name << ".function\n";
} }
}
static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S, static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
formatted_raw_ostream &OS, formatted_raw_ostream &OS,

View File

@ -14,13 +14,13 @@
#ifndef LLVM_LIB_TARGET_XCORE_MCTARGETDESC_XCOREMCTARGETDESC_H #ifndef LLVM_LIB_TARGET_XCORE_MCTARGETDESC_XCOREMCTARGETDESC_H
#define LLVM_LIB_TARGET_XCORE_MCTARGETDESC_XCOREMCTARGETDESC_H #define LLVM_LIB_TARGET_XCORE_MCTARGETDESC_XCOREMCTARGETDESC_H
#include "llvm/Support/DataTypes.h"
namespace llvm { namespace llvm {
class Target; class Target;
Target &getTheXCoreTarget(); Target &getTheXCoreTarget();
} // End llvm namespace } // end namespace llvm
// Defines symbolic names for XCore registers. This defines a mapping from // Defines symbolic names for XCore registers. This defines a mapping from
// register name to register number. // register name to register number.
@ -36,4 +36,4 @@ Target &getTheXCoreTarget();
#define GET_SUBTARGETINFO_ENUM #define GET_SUBTARGETINFO_ENUM
#include "XCoreGenSubtargetInfo.inc" #include "XCoreGenSubtargetInfo.inc"
#endif #endif // LLVM_LIB_TARGET_XCORE_MCTARGETDESC_XCOREMCTARGETDESC_H

View File

@ -14,50 +14,39 @@
#ifndef LLVM_LIB_TARGET_XCORE_XCOREMACHINEFUNCTIONINFO_H #ifndef LLVM_LIB_TARGET_XCORE_XCOREMACHINEFUNCTIONINFO_H
#define LLVM_LIB_TARGET_XCORE_XCOREMACHINEFUNCTIONINFO_H #define LLVM_LIB_TARGET_XCORE_XCOREMACHINEFUNCTIONINFO_H
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunction.h"
#include <cassert>
#include <utility>
#include <vector> #include <vector>
namespace llvm { namespace llvm {
// Forward declarations
class Function;
/// XCoreFunctionInfo - This class is derived from MachineFunction private /// XCoreFunctionInfo - This class is derived from MachineFunction private
/// XCore target-specific information for each MachineFunction. /// XCore target-specific information for each MachineFunction.
class XCoreFunctionInfo : public MachineFunctionInfo { class XCoreFunctionInfo : public MachineFunctionInfo {
virtual void anchor(); bool LRSpillSlotSet = false;
bool LRSpillSlotSet;
int LRSpillSlot; int LRSpillSlot;
bool FPSpillSlotSet; bool FPSpillSlotSet = false;
int FPSpillSlot; int FPSpillSlot;
bool EHSpillSlotSet; bool EHSpillSlotSet = false;
int EHSpillSlot[2]; int EHSpillSlot[2];
unsigned ReturnStackOffset; unsigned ReturnStackOffset;
bool ReturnStackOffsetSet; bool ReturnStackOffsetSet = false;
int VarArgsFrameIndex; int VarArgsFrameIndex = 0;
mutable int CachedEStackSize; mutable int CachedEStackSize = -1;
std::vector<std::pair<MachineBasicBlock::iterator, CalleeSavedInfo>> std::vector<std::pair<MachineBasicBlock::iterator, CalleeSavedInfo>>
SpillLabels; SpillLabels;
virtual void anchor();
public: public:
XCoreFunctionInfo() : XCoreFunctionInfo() = default;
LRSpillSlotSet(false),
FPSpillSlotSet(false),
EHSpillSlotSet(false),
ReturnStackOffsetSet(false),
VarArgsFrameIndex(0),
CachedEStackSize(-1) {}
explicit XCoreFunctionInfo(MachineFunction &MF) : explicit XCoreFunctionInfo(MachineFunction &MF) {}
LRSpillSlotSet(false),
FPSpillSlotSet(false),
EHSpillSlotSet(false),
ReturnStackOffsetSet(false),
VarArgsFrameIndex(0),
CachedEStackSize(-1) {}
~XCoreFunctionInfo() {} ~XCoreFunctionInfo() override = default;
void setVarArgsFrameIndex(int off) { VarArgsFrameIndex = off; } void setVarArgsFrameIndex(int off) { VarArgsFrameIndex = off; }
int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
@ -101,6 +90,7 @@ public:
return SpillLabels; return SpillLabels;
} }
}; };
} // End llvm namespace
#endif } // end namespace llvm
#endif // LLVM_LIB_TARGET_XCORE_XCOREMACHINEFUNCTIONINFO_H

View File

@ -10,15 +10,19 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "MCTargetDesc/XCoreMCTargetDesc.h"
#include "XCore.h"
#include "XCoreTargetMachine.h" #include "XCoreTargetMachine.h"
#include "XCoreTargetObjectFile.h" #include "XCoreTargetObjectFile.h"
#include "XCoreTargetTransformInfo.h" #include "XCoreTargetTransformInfo.h"
#include "XCore.h" #include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/Module.h" #include "llvm/Support/CodeGen.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/Support/TargetRegistry.h" #include "llvm/Support/TargetRegistry.h"
using namespace llvm; using namespace llvm;
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) { static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
@ -38,14 +42,15 @@ XCoreTargetMachine::XCoreTargetMachine(const Target &T, const Triple &TT,
: LLVMTargetMachine( : LLVMTargetMachine(
T, "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32", T, "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32",
TT, CPU, FS, Options, getEffectiveRelocModel(RM), CM, OL), TT, CPU, FS, Options, getEffectiveRelocModel(RM), CM, OL),
TLOF(make_unique<XCoreTargetObjectFile>()), TLOF(llvm::make_unique<XCoreTargetObjectFile>()),
Subtarget(TT, CPU, FS, *this) { Subtarget(TT, CPU, FS, *this) {
initAsmInfo(); initAsmInfo();
} }
XCoreTargetMachine::~XCoreTargetMachine() {} XCoreTargetMachine::~XCoreTargetMachine() = default;
namespace { namespace {
/// XCore Code Generator Pass Configuration Options. /// XCore Code Generator Pass Configuration Options.
class XCorePassConfig : public TargetPassConfig { class XCorePassConfig : public TargetPassConfig {
public: public:
@ -61,7 +66,8 @@ public:
bool addInstSelector() override; bool addInstSelector() override;
void addPreEmitPass() override; void addPreEmitPass() override;
}; };
} // namespace
} // end anonymous namespace
TargetPassConfig *XCoreTargetMachine::createPassConfig(PassManagerBase &PM) { TargetPassConfig *XCoreTargetMachine::createPassConfig(PassManagerBase &PM) {
return new XCorePassConfig(this, PM); return new XCorePassConfig(this, PM);

View File

@ -15,13 +15,19 @@
#define LLVM_LIB_TARGET_XCORE_XCORETARGETMACHINE_H #define LLVM_LIB_TARGET_XCORE_XCORETARGETMACHINE_H
#include "XCoreSubtarget.h" #include "XCoreSubtarget.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#include <memory>
namespace llvm { namespace llvm {
class XCoreTargetMachine : public LLVMTargetMachine { class XCoreTargetMachine : public LLVMTargetMachine {
std::unique_ptr<TargetLoweringObjectFile> TLOF; std::unique_ptr<TargetLoweringObjectFile> TLOF;
XCoreSubtarget Subtarget; XCoreSubtarget Subtarget;
public: public:
XCoreTargetMachine(const Target &T, const Triple &TT, StringRef CPU, XCoreTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
StringRef FS, const TargetOptions &Options, StringRef FS, const TargetOptions &Options,
@ -38,6 +44,7 @@ public:
TargetPassConfig *createPassConfig(PassManagerBase &PM) override; TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
TargetIRAnalysis getTargetIRAnalysis() override; TargetIRAnalysis getTargetIRAnalysis() override;
TargetLoweringObjectFile *getObjFileLowering() const override { TargetLoweringObjectFile *getObjFileLowering() const override {
return TLOF.get(); return TLOF.get();
} }
@ -45,4 +52,4 @@ public:
} // end namespace llvm } // end namespace llvm
#endif #endif // LLVM_LIB_TARGET_XCORE_XCORETARGETMACHINE_H