Skip to content

Commit bc879c7

Browse files
Anton Sidorenkoigcbot
authored andcommitted
LLVM 13 related changes
Contains a number of small changes: * CloneFunctionInto * fs::F_None -> fs::OF_None * getUserCost fix * include std::stack * ConstantAggregateZero getElementCount helper function * OptTable printHelp
1 parent 623c16b commit bc879c7

File tree

11 files changed

+101
-10
lines changed

11 files changed

+101
-10
lines changed

IGC/Options/src/Options.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ SPDX-License-Identifier: MIT
1212

1313
using namespace IGC::options;
1414
using namespace llvm::opt;
15+
using llvm::raw_ostream;
1516

1617
#define PREFIX(NAME, VALUE) static const char *const API_##NAME[] = VALUE;
1718
#include "igc/Options/ApiOptions.inc"

IGC/VectorCompiler/CMCL/tools/Translator/Main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ SPDX-License-Identifier: MIT
1818
#include <llvm/Support/InitLLVM.h>
1919
#include <llvm/Support/SourceMgr.h>
2020
#include <llvm/Support/ToolOutputFile.h>
21+
#include <llvm/Support/FileSystem.h>
2122

2223
using namespace llvm;
2324

IGC/VectorCompiler/lib/Driver/Driver.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ SPDX-License-Identifier: MIT
5353
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
5454
#include "llvm/Transforms/Scalar.h"
5555

56+
#include "llvmWrapper/Option/OptTable.h"
5657
#include "llvmWrapper/Target/TargetMachine.h"
5758

5859
#include "Probe/Assertion.h"
@@ -668,8 +669,8 @@ static Error fillInternalOptions(const opt::ArgList &InternalOptions,
668669
constexpr unsigned FlagsToInclude = IGC::options::VCApiOption;
669670
constexpr unsigned FlagsToExclude = 0;
670671
constexpr bool ShowAllAliases = false;
671-
IGC::getApiOptTable().PrintHelp(llvm::errs(), Usage, Title, FlagsToInclude,
672-
FlagsToExclude, ShowAllAliases);
672+
IGCLLVM::printHelp(IGC::getApiOptTable(), llvm::errs(), Usage, Title,
673+
FlagsToInclude, FlagsToExclude, ShowAllAliases);
673674
}
674675
if (InternalOptions.hasArg(OPT_help_internal)) {
675676
constexpr const char *Usage =
@@ -678,9 +679,8 @@ static Error fillInternalOptions(const opt::ArgList &InternalOptions,
678679
constexpr unsigned FlagsToInclude = IGC::options::VCInternalOption;
679680
constexpr unsigned FlagsToExclude = 0;
680681
constexpr bool ShowAllAliases = false;
681-
IGC::getInternalOptTable().PrintHelp(llvm::errs(), Usage, Title,
682-
FlagsToInclude, FlagsToExclude,
683-
ShowAllAliases);
682+
IGCLLVM::printHelp(IGC::getInternalOptTable(), llvm::errs(), Usage, Title,
683+
FlagsToInclude, FlagsToExclude, ShowAllAliases);
684684
}
685685

686686
return Error::success();

IGC/VectorCompiler/lib/GenXCodeGen/GenXAnalysisDumper.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ static int openFileForDump(Function *F, StringRef Suffix)
9595
// Sanitize templated kernel names.
9696
std::replace_if(Filename.begin(), Filename.end(),
9797
[](const char x) { return x == '<' || x == '>'; }, '_');
98-
auto EC = sys::fs::openFileForWrite(Filename, FD, sys::fs::CD_CreateAlways, sys::fs::F_None);
98+
auto EC = sys::fs::openFileForWrite(Filename, FD, sys::fs::CD_CreateAlways,
99+
sys::fs::OF_None);
99100
if (EC) {
100101
errs() << "Error: " << EC.message() << "\n";
101102
return -1;

IGC/VectorCompiler/lib/GenXCodeGen/GenXOCLRuntimeInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ SPDX-License-Identifier: MIT
3131
#include <cctype>
3232
#include <functional>
3333
#include <iterator>
34+
#include <stack>
3435

3536
#include "Probe/Assertion.h"
3637

IGC/VectorCompiler/lib/GenXCodeGen/GenXPatternMatch.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ SPDX-License-Identifier: MIT
7575
#include "llvm/Target/TargetOptions.h"
7676
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
7777

78+
#include "llvmWrapper/IR/Constants.h"
7879
#include "llvmWrapper/IR/DerivedTypes.h"
7980
#include "llvmWrapper/Support/TypeSize.h"
8081
#include "llvmWrapper/Transforms/Utils/Local.h"
@@ -1834,7 +1835,7 @@ bool MinMaxMatcher::valuesMatch(llvm::Value *Op1, llvm::Value *Op2) {
18341835
if (isa<ConstantAggregateZero>(Op1) && isa<ConstantAggregateZero>(Op2)) {
18351836
ConstantAggregateZero *C1 = cast<ConstantAggregateZero>(Op1);
18361837
ConstantAggregateZero *C2 = cast<ConstantAggregateZero>(Op2);
1837-
if (C1->getNumElements() != C2->getNumElements())
1838+
if (IGCLLVM::getElementCount(*C1) != IGCLLVM::getElementCount(*C2))
18381839
return false;
18391840
Type *C1Ty = C1->getType();
18401841
Type *C2Ty = C2->getType();

IGC/VectorCompiler/lib/GenXCodeGen/GenXTargetMachine.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ class GenXTTIImpl : public TargetTransformInfoImplCRTPBase<GenXTTIImpl>
9797
bool shouldBuildLookupTables() { return false; }
9898
unsigned getFlatAddressSpace() { return 4; }
9999

100-
int getUserCost(const User *U, ArrayRef<const Value *> Operands
100+
#if LLVM_VERSION_MAJOR >= 13
101+
InstructionCost
102+
#else
103+
int
104+
#endif
105+
getUserCost(const User *U, ArrayRef<const Value *> Operands
101106
#if LLVM_VERSION_MAJOR >= 11
102107
,
103108
TTI::TargetCostKind CostKind

IGC/VectorCompiler/lib/GenXOpts/CMPacketize/GenXPacketize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ SPDX-License-Identifier: MIT
2323
#include "llvmWrapper/IR/DerivedTypes.h"
2424
#include "llvmWrapper/Support/Alignment.h"
2525
#include "llvmWrapper/IR/Instructions.h"
26+
#include "llvmWrapper/Transforms/Utils/Cloning.h"
2627

2728
#include "vc/GenXOpts/Utils/CMRegion.h"
2829

@@ -322,7 +323,7 @@ Function *GenXPacketize::vectorizeSIMTFunction(Function *F, unsigned Width) {
322323
}
323324
SmallVector<ReturnInst *, 10> returns;
324325
ClonedCodeInfo CloneInfo;
325-
CloneFunctionInto(ClonedFunc, F, ArgMap, true, returns, Suffix[Width / 8],
326+
IGCLLVM::CloneFunctionInto(ClonedFunc, F, ArgMap, true, returns, Suffix[Width / 8],
326327
&CloneInfo);
327328

328329
ReplaceMap.clear();

IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXImportOCLBiF.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ SPDX-License-Identifier: MIT
4444
#include <llvm/Transforms/Utils/Cloning.h>
4545
#include <llvm/Transforms/Utils/ValueMapper.h>
4646
#include <llvmWrapper/IR/Instructions.h>
47+
#include "llvmWrapper/Transforms/Utils/Cloning.h"
4748

4849
#include <algorithm>
4950
#include <iterator>
@@ -387,7 +388,7 @@ static void removeFunctionBitcasts(Module &M) {
387388

388389
// Clone the body of the function into the dest function.
389390
SmallVector<ReturnInst *, 8> Returns; // Ignore returns.
390-
CloneFunctionInto(pDstFunc, funcTobeChanged, operandMap, false,
391+
IGCLLVM::CloneFunctionInto(pDstFunc, funcTobeChanged, operandMap, false,
391392
Returns, "");
392393

393394
pDstFunc->setCallingConv(funcTobeChanged->getCallingConv());
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*========================== begin_copyright_notice ============================
2+
3+
Copyright (C) 2019-2021 Intel Corporation
4+
5+
SPDX-License-Identifier: MIT
6+
7+
============================= end_copyright_notice ===========================*/
8+
9+
#ifndef IGCLLVM_IR_CONSTANTS_H
10+
#define IGCLLVM_IR_CONSTANTS_H
11+
12+
#include "llvm/Config/llvm-config.h"
13+
#include "llvm/IR/Constants.h"
14+
15+
#if LLVM_VERSION_MAJOR > 12
16+
#include "llvm/Support/TypeSize.h"
17+
#endif
18+
19+
namespace IGCLLVM
20+
{
21+
inline
22+
#if LLVM_VERSION_MAJOR <= 12
23+
unsigned
24+
#else
25+
llvm::ElementCount
26+
#endif
27+
getElementCount(const llvm::ConstantAggregateZero &C) {
28+
#if LLVM_VERSION_MAJOR <= 12
29+
return C.getNumElements();
30+
#else
31+
return C.getElementCount();
32+
#endif
33+
}
34+
}
35+
36+
#endif
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*========================== begin_copyright_notice ============================
2+
3+
Copyright (C) 2019-2021 Intel Corporation
4+
5+
SPDX-License-Identifier: MIT
6+
7+
============================= end_copyright_notice ===========================*/
8+
9+
#ifndef IGCLLVM_OPTION_OPTTABLE_H
10+
#define IGCLLVM_OPTION_OPTTABLE_H
11+
12+
#include "llvm/Config/llvm-config.h"
13+
#include "llvm/Option/OptTable.h"
14+
#include "llvm/Support/raw_ostream.h"
15+
16+
namespace IGCLLVM {
17+
inline void printHelp(const llvm::opt::OptTable &Options, llvm::raw_ostream &OS,
18+
const char *Usage, const char *Title,
19+
unsigned FlagsToInclude, unsigned FlagsToExclude,
20+
bool ShowAllAliases) {
21+
Options.
22+
#if LLVM_VERSION_MAJOR <= 12
23+
PrintHelp
24+
#else
25+
printHelp
26+
#endif
27+
(OS, Usage, Title, FlagsToInclude, FlagsToExclude, ShowAllAliases);
28+
}
29+
30+
inline void printHelp(const llvm::opt::OptTable &Options, llvm::raw_ostream &OS,
31+
const char *Usage, const char *Title,
32+
bool ShowHidden = false, bool ShowAllAliases = false) {
33+
Options.
34+
#if LLVM_VERSION_MAJOR <= 12
35+
PrintHelp
36+
#else
37+
printHelp
38+
#endif
39+
(OS, Usage, Title, ShowHidden, ShowAllAliases);
40+
}
41+
} // namespace IGCLLVM
42+
43+
#endif

0 commit comments

Comments
 (0)