Skip to content

Commit

Permalink
[ARM] Fix some Clang-tidy modernize-use-using and Include What You Us…
Browse files Browse the repository at this point in the history
…e warnings; other minor fixes (NFC).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313823 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
EugeneZelenko committed Sep 20, 2017
1 parent 26d9773 commit 20d1cb1
Show file tree
Hide file tree
Showing 17 changed files with 456 additions and 233 deletions.
50 changes: 40 additions & 10 deletions lib/Target/ARM/ARMCallLowering.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,52 @@
//===-- llvm/lib/Target/ARM/ARMCallLowering.cpp - Call lowering -----------===//
//===- llvm/lib/Target/ARM/ARMCallLowering.cpp - Call lowering ------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
//
/// \file
/// This file implements the lowering of LLVM calls to machine code calls for
/// GlobalISel.
///
//
//===----------------------------------------------------------------------===//

#include "ARMCallLowering.h"

#include "ARMBaseInstrInfo.h"
#include "ARMISelLowering.h"
#include "ARMSubtarget.h"

#include "Utils/ARMBaseInfo.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
#include "llvm/CodeGen/GlobalISel/Utils.h"
#include "llvm/CodeGen/LowLevelType.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/MachineValueType.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/LowLevelTypeImpl.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetSubtargetInfo.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <utility>

using namespace llvm;

Expand Down Expand Up @@ -59,12 +83,13 @@ static bool isSupportedType(const DataLayout &DL, const ARMTargetLowering &TLI,
}

namespace {

/// Helper class for values going out through an ABI boundary (used for handling
/// function return values and call parameters).
struct OutgoingValueHandler : public CallLowering::ValueHandler {
OutgoingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI,
MachineInstrBuilder &MIB, CCAssignFn *AssignFn)
: ValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB), StackSize(0) {}
: ValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {}

unsigned getStackAddress(uint64_t Size, int64_t Offset,
MachinePointerInfo &MPO) override {
Expand Down Expand Up @@ -153,9 +178,10 @@ struct OutgoingValueHandler : public CallLowering::ValueHandler {
}

MachineInstrBuilder &MIB;
uint64_t StackSize;
uint64_t StackSize = 0;
};
} // End anonymous namespace.

} // end anonymous namespace

void ARMCallLowering::splitToValueTypes(
const ArgInfo &OrigArg, SmallVectorImpl<ArgInfo> &SplitArgs,
Expand Down Expand Up @@ -259,6 +285,7 @@ bool ARMCallLowering::lowerReturn(MachineIRBuilder &MIRBuilder,
}

namespace {

/// Helper class for values coming in through an ABI boundary (used for handling
/// formal arguments and call return values).
struct IncomingValueHandler : public CallLowering::ValueHandler {
Expand Down Expand Up @@ -371,7 +398,8 @@ struct FormalArgHandler : public IncomingValueHandler {
MIRBuilder.getMBB().addLiveIn(PhysReg);
}
};
} // End anonymous namespace

} // end anonymous namespace

bool ARMCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
const Function &F,
Expand Down Expand Up @@ -429,6 +457,7 @@ bool ARMCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
}

namespace {

struct CallReturnHandler : public IncomingValueHandler {
CallReturnHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI,
MachineInstrBuilder MIB, CCAssignFn *AssignFn)
Expand All @@ -440,7 +469,8 @@ struct CallReturnHandler : public IncomingValueHandler {

MachineInstrBuilder MIB;
};
} // End anonymous namespace.

} // end anonymous namespace

bool ARMCallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
CallingConv::ID CallConv,
Expand Down
27 changes: 17 additions & 10 deletions lib/Target/ARM/ARMCallLowering.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
//===-- llvm/lib/Target/ARM/ARMCallLowering.h - Call lowering -------------===//
//===- llvm/lib/Target/ARM/ARMCallLowering.h - Call lowering ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
//
/// \file
/// This file describes how to lower LLVM calls to machine code calls.
///
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIB_TARGET_ARM_ARMCALLLOWERING
#define LLVM_LIB_TARGET_ARM_ARMCALLLOWERING
#ifndef LLVM_LIB_TARGET_ARM_ARMCALLLOWERING_H
#define LLVM_LIB_TARGET_ARM_ARMCALLLOWERING_H

#include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/IR/CallingConv.h"
#include <cstdint>
#include <functional>

namespace llvm {

class ARMTargetLowering;
class MachineFunction;
class MachineInstrBuilder;
class MachineIRBuilder;
class Value;

class ARMCallLowering : public CallLowering {
public:
Expand All @@ -42,7 +47,7 @@ class ARMCallLowering : public CallLowering {
bool lowerReturnVal(MachineIRBuilder &MIRBuilder, const Value *Val,
unsigned VReg, MachineInstrBuilder &Ret) const;

typedef std::function<void(unsigned Reg, uint64_t Offset)> SplitArgTy;
using SplitArgTy = std::function<void(unsigned Reg, uint64_t Offset)>;

/// Split an argument into one or more arguments that the CC lowering can cope
/// with (e.g. replace pointers with integers).
Expand All @@ -51,5 +56,7 @@ class ARMCallLowering : public CallLowering {
MachineFunction &MF,
const SplitArgTy &PerformArgSplit) const;
};
} // End of namespace llvm
#endif

} // end namespace llvm

#endif // LLVM_LIB_TARGET_ARM_ARMCALLLOWERING_H
28 changes: 12 additions & 16 deletions lib/Target/ARM/ARMConstantIslandPass.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- ARMConstantIslandPass.cpp - ARM constant islands ------------------===//
//===- ARMConstantIslandPass.cpp - ARM constant islands -------------------===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -20,6 +20,7 @@
#include "ARMSubtarget.h"
#include "MCTargetDesc/ARMBaseInfo.h"
#include "Thumb2InstrInfo.h"
#include "Utils/ARMBaseInfo.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"
Expand All @@ -37,6 +38,7 @@
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
Expand All @@ -48,7 +50,6 @@
#include <cassert>
#include <cstdint>
#include <iterator>
#include <new>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -107,7 +108,7 @@ namespace {
/// previous iteration by inserting unconditional branches.
SmallSet<MachineBasicBlock*, 4> NewWaterList;

typedef std::vector<MachineBasicBlock*>::iterator water_iterator;
using water_iterator = std::vector<MachineBasicBlock *>::iterator;

/// CPUser - One user of a constant pool, keeping the machine instruction
/// pointer, the constant pool being referenced, and the max displacement
Expand All @@ -128,12 +129,11 @@ namespace {
unsigned MaxDisp;
bool NegOk;
bool IsSoImm;
bool KnownAlignment;
bool KnownAlignment = false;

CPUser(MachineInstr *mi, MachineInstr *cpemi, unsigned maxdisp,
bool neg, bool soimm)
: MI(mi), CPEMI(cpemi), MaxDisp(maxdisp), NegOk(neg), IsSoImm(soimm),
KnownAlignment(false) {
: MI(mi), CPEMI(cpemi), MaxDisp(maxdisp), NegOk(neg), IsSoImm(soimm) {
HighWaterMark = CPEMI->getParent();
}

Expand Down Expand Up @@ -195,11 +195,9 @@ namespace {
};

/// ImmBranches - Keep track of all the immediate branch instructions.
///
std::vector<ImmBranch> ImmBranches;

/// PushPopMIs - Keep track of all the Thumb push / pop instructions.
///
SmallVector<MachineInstr*, 4> PushPopMIs;

/// T2JumpTables - Keep track of all the Thumb2 jumptable instructions.
Expand Down Expand Up @@ -290,10 +288,10 @@ namespace {
}
};

char ARMConstantIslands::ID = 0;

} // end anonymous namespace

char ARMConstantIslands::ID = 0;

/// verify - check BBOffsets, BBSizes, alignment of islands
void ARMConstantIslands::verify() {
#ifndef NDEBUG
Expand Down Expand Up @@ -629,9 +627,9 @@ bool ARMConstantIslands::BBHasFallthrough(MachineBasicBlock *MBB) {

/// findConstPoolEntry - Given the constpool index and CONSTPOOL_ENTRY MI,
/// look up the corresponding CPEntry.
ARMConstantIslands::CPEntry
*ARMConstantIslands::findConstPoolEntry(unsigned CPI,
const MachineInstr *CPEMI) {
ARMConstantIslands::CPEntry *
ARMConstantIslands::findConstPoolEntry(unsigned CPI,
const MachineInstr *CPEMI) {
std::vector<CPEntry> &CPEs = CPEntries[CPI];
// Number of entries per constpool index should be small, just do a
// linear search.
Expand Down Expand Up @@ -1126,7 +1124,6 @@ void ARMConstantIslands::adjustBBOffsetsAfter(MachineBasicBlock *BB) {
/// and instruction CPEMI, and decrement its refcount. If the refcount
/// becomes 0 remove the entry and instruction. Returns true if we removed
/// the entry, false if we didn't.

bool ARMConstantIslands::decrementCPEReferenceCount(unsigned CPI,
MachineInstr *CPEMI) {
// Find the old entry. Eliminate it if it is no longer used.
Expand Down Expand Up @@ -1154,8 +1151,7 @@ unsigned ARMConstantIslands::getCombinedIndex(const MachineInstr *CPEMI) {
/// 0 = no existing entry found
/// 1 = entry found, and there were no code insertions or deletions
/// 2 = entry found, and there were code insertions or deletions
int ARMConstantIslands::findInRangeCPEntry(CPUser& U, unsigned UserOffset)
{
int ARMConstantIslands::findInRangeCPEntry(CPUser& U, unsigned UserOffset) {
MachineInstr *UserMI = U.MI;
MachineInstr *CPEMI = U.CPEMI;

Expand Down
3 changes: 1 addition & 2 deletions lib/Target/ARM/ARMConstantPoolValue.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- ARMConstantPoolValue.cpp - ARM constantpool value -----------------===//
//===- ARMConstantPoolValue.cpp - ARM constantpool value ------------------===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -13,7 +13,6 @@

#include "ARMConstantPoolValue.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
Expand Down
10 changes: 7 additions & 3 deletions lib/Target/ARM/ARMConstantPoolValue.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- ARMConstantPoolValue.h - ARM constantpool value ---------*- C++ -*-===//
//===- ARMConstantPoolValue.h - ARM constantpool value ----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -14,8 +14,9 @@
#ifndef LLVM_LIB_TARGET_ARM_ARMCONSTANTPOOLVALUE_H
#define LLVM_LIB_TARGET_ARM_ARMCONSTANTPOOLVALUE_H

#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/Support/Casting.h"
#include <string>
Expand All @@ -29,6 +30,8 @@ class GlobalValue;
class GlobalVariable;
class LLVMContext;
class MachineBasicBlock;
class raw_ostream;
class Type;

namespace ARMCP {

Expand Down Expand Up @@ -174,7 +177,8 @@ class ARMConstantPoolConstant : public ARMConstantPoolValue {
const GlobalValue *getGV() const;
const BlockAddress *getBlockAddress() const;

typedef SmallPtrSet<const GlobalVariable *, 1>::iterator promoted_iterator;
using promoted_iterator = SmallPtrSet<const GlobalVariable *, 1>::iterator;

iterator_range<promoted_iterator> promotedGlobals() {
return iterator_range<promoted_iterator>(GVars.begin(), GVars.end());
}
Expand Down
Loading

0 comments on commit 20d1cb1

Please sign in to comment.