Skip to content

Commit fdda08a

Browse files
DianaChensys_zuul
authored and
sys_zuul
committed
IGA Refactoring and minor bug fix:
- Add kv api: Instruction::getSubfunction - Rename EncoderBase to Encoder - Constexpr fix - Fixes for 32b warnings Change-Id: I52d1f9281e67640e5f370785dad0d543cc344550
1 parent d9e62ba commit fdda08a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1276
-1289
lines changed

visa/iga/IGAExe/CMakeLists.txt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ set(IGA_EXE_CPP
1313
${CMAKE_CURRENT_SOURCE_DIR}/decode_message.cpp
1414
${CMAKE_CURRENT_SOURCE_DIR}/iga_main.cpp
1515
${CMAKE_CURRENT_SOURCE_DIR}/list_ops.cpp
16-
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
17-
)
16+
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
1817

1918
set(IGA_EXE_HPP
2019
${CMAKE_CURRENT_SOURCE_DIR}/fatal.hpp
2120
${CMAKE_CURRENT_SOURCE_DIR}/iga_main.hpp
2221
${CMAKE_CURRENT_SOURCE_DIR}/io.hpp
23-
${CMAKE_CURRENT_SOURCE_DIR}/opts.hpp
24-
)
22+
${CMAKE_CURRENT_SOURCE_DIR}/opts.hpp)
2523

2624
source_group("HeaderFiles" FILES ${IGA_EXE_HPP})
2725
source_group("SourceFiles" FILES ${IGA_EXE_CPP})
@@ -30,6 +28,19 @@ set(IGA_EXE_DEFINITIONS _CONSOLE _LIB ${GED_BRANCH})
3028

3129
if(MSVC)
3230
add_compile_options(/EHsc)
31+
32+
# unhandled enum case not handled in switch (from comp/igc I believe)
33+
add_compile_options(/w14062)
34+
# add_compile_options(/w14100) # unreferenced parameter. Enable caused Release build failure
35+
add_compile_options(/w14189) # unreachable code
36+
add_compile_options(/w14244) # implicit narrowing
37+
add_compile_options(/w14245) # signed/unsigned conversion
38+
add_compile_options(/w14389) # signed/unsigned compare
39+
# add_compile_options(/w14456) # var name shadows outer scope var
40+
# add_compile_options(/w14458) # var name shadows field
41+
add_compile_options(/w14505) # unreferenced local function (static)
42+
43+
add_compile_options(/WX)
3344
else(MSVC)
3445
add_compile_options(-fexceptions)
3546
endif(MSVC)

visa/iga/IGAExe/assemble.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ bool assemble(
4343
bool assemble(
4444
const Opts &opts,
4545
igax::Context &ctx,
46-
const std::string &inpFile,
46+
const std::string &,
4747
const std::string &inpText,
4848
igax::Bits &bits)
4949
{

visa/iga/IGAExe/decode_fields.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static void parseBitsAsHex(
138138
return -1;
139139
}
140140
int digit = 0;
141-
char chr = ::toupper(inp[off]);
141+
char chr = (char)::toupper(inp[off]);
142142
if (chr >= '0' && chr <= '9') {
143143
digit = chr - '0';
144144
} else if (chr >= 'A' && chr <= 'F') {
@@ -268,17 +268,6 @@ static igax::Bits parseBits(const std::string &inp, Opts &opts)
268268
return bits;
269269
}
270270

271-
static void checkPlatform(Opts &opts)
272-
{
273-
if (opts.platform == IGA_GEN_INVALID) {
274-
if (!opts.inputFiles.empty() && opts.mode != Opts::Mode::XDSD) {
275-
// mode will be ignored, don't worry
276-
inferPlatformAndMode(opts.inputFiles[0], opts);
277-
}
278-
ensurePlatformIsSet(opts);
279-
} // else -p=... was given
280-
}
281-
282271
static bool decodeFieldsSingle(Opts opts)
283272
{
284273
inferPlatformAndMode(opts.inputFiles[0], opts);

visa/iga/IGAExe/decode_message.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void emitRegName(std::ostream &os, int grfNum) {
6767
}
6868

6969
static void formatSIMT(
70-
const Opts &opts,
70+
const Opts &,
7171
std::ostream &os,
7272
const iga::MessageInfo &mi,
7373
int grfSizeB)
@@ -100,7 +100,7 @@ static void formatSIMT(
100100
}
101101

102102
static void formatSIMD(
103-
const Opts &opts,
103+
const Opts &,
104104
std::ostream &os,
105105
const iga::MessageInfo &mi,
106106
int grfSizeB)
@@ -141,6 +141,8 @@ static void formatSIMD(
141141
}
142142
}
143143

144+
static char toLower(char c) {return (char)std::tolower(c);}
145+
144146
bool decodeSendDescriptor(const Opts &opts)
145147
{
146148
std::ofstream ofs(opts.outputFile);
@@ -157,7 +159,7 @@ bool decodeSendDescriptor(const Opts &opts)
157159
inp = inp.substr(3);
158160
iga::RegRef a0rr;
159161
try {
160-
a0rr.subRegNum = (uint8_t)std::stoul(inp, nullptr, 10);
162+
a0rr.subRegNum = (uint16_t)std::stoul(inp, nullptr, 10);
161163
} catch (...) {
162164
fatalExitWithMessage(
163165
"-Xdsd: %s: %s: invalid a0 subregister",
@@ -190,7 +192,7 @@ bool decodeSendDescriptor(const Opts &opts)
190192
if (opts.inputFiles.size() == 3) {
191193
std::string sfidSym = opts.inputFiles[0];
192194
std::transform(
193-
sfidSym.begin(), sfidSym.end(), sfidSym.begin(), ::tolower);
195+
sfidSym.begin(), sfidSym.end(), sfidSym.begin(), toLower);
194196
sfid = iga::FromSyntax<iga::SFID>(sfidSym);
195197
if (sfid == iga::SFID::INVALID) {
196198
fatalExitWithMessage(

visa/iga/IGAExe/iga_main.cpp

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ extern "C" int iga_main(int argc, const char **argv)
6464
"Without this iga attempts to infer the mode based on the extension. "
6565
"Files ending in '.krn' are assumed binary without this option.",
6666
opts::OptAttrs::ALLOW_UNSET,
67-
[] (const char *, const opts::ErrorHandler &eh, Opts &baseOpts) {
67+
[] (const char *, const opts::ErrorHandler &, Opts &baseOpts) {
6868
baseOpts.mode = Opts::Mode::DIS;
6969
});
7070
cmdline.defineFlag(
@@ -75,7 +75,7 @@ extern "C" int iga_main(int argc, const char **argv)
7575
"Without this iga attempts to infer the mode based on the extension. "
7676
"Files ending in '.asm' are assumed syntax input without this option.",
7777
opts::OptAttrs::ALLOW_UNSET,
78-
[] (const char *, const opts::ErrorHandler &eh, Opts &baseOpts) {
78+
[] (const char *, const opts::ErrorHandler &, Opts &baseOpts) {
7979
baseOpts.mode = Opts::Mode::ASM;
8080
});
8181
cmdline.defineOpt(
@@ -105,7 +105,7 @@ extern "C" int iga_main(int argc, const char **argv)
105105
"labels will be in bytes relative to the IP pre-increment "
106106
"(even for jmpi and on HSW)",
107107
opts::OptAttrs::ALLOW_UNSET,
108-
[] (const char *, const opts::ErrorHandler &eh, Opts &baseOpts) {
108+
[] (const char *, const opts::ErrorHandler &, Opts &baseOpts) {
109109
baseOpts.numericLabels = true;
110110
});
111111
cmdline.defineFlag(
@@ -114,7 +114,7 @@ extern "C" int iga_main(int argc, const char **argv)
114114
"lower verbosity output",
115115
"This is the same as -v=-1",
116116
opts::OptAttrs::ALLOW_UNSET,
117-
[] (const char *, const opts::ErrorHandler &eh, Opts &baseOpts) {
117+
[] (const char *, const opts::ErrorHandler &, Opts &baseOpts) {
118118
baseOpts.verbosity = -1;
119119
});
120120
cmdline.defineOpt(
@@ -185,20 +185,17 @@ extern "C" int iga_main(int argc, const char **argv)
185185
inp = inp.substr(3); // gen9 -> 9
186186
//
187187
for (const auto &pt : platforms) {
188-
std::string pnm = pt.suffix;
188+
std::string pnm = normalizePlatformName(pt.suffix);
189189
// try IGA-preferred names first (e.g. "12p1")
190190
// normalized the IGA-returned platform name to lowercase
191-
std::transform(
192-
pnm.begin(), pnm.end(), pnm.begin(), ::tolower);
193191
if (pnm == inp) {
194192
baseOpts.platform = pt.toGen();
195193
return; // bail out
196194
}
197195
// Try library returned names second (e.g. "skl")
198196
for (std::string pnm : pt.names) {
199197
// normalized the IGA-returned platform name to lowercase
200-
std::transform(
201-
pnm.begin(), pnm.end(), pnm.begin(), ::tolower);
198+
pnm = normalizePlatformName(pnm);
202199
if (pnm == inp) {
203200
baseOpts.platform = pt.toGen();
204201
return;
@@ -229,7 +226,7 @@ extern "C" int iga_main(int argc, const char **argv)
229226
"disables all warnings",
230227
nullptr,
231228
opts::OptAttrs::ALLOW_UNSET,
232-
[] (const char *cinp, const opts::ErrorHandler err, Opts &baseOpts) {
229+
[] (const char *, const opts::ErrorHandler, Opts &baseOpts) {
233230
baseOpts.enabledWarnings = IGA_WARNINGS_NONE;
234231
});
235232
wGrp.defineFlag(
@@ -238,7 +235,7 @@ extern "C" int iga_main(int argc, const char **argv)
238235
"enables all warnings",
239236
nullptr,
240237
opts::OptAttrs::ALLOW_UNSET,
241-
[] (const char *cinp, const opts::ErrorHandler err, Opts &baseOpts) {
238+
[] (const char *, const opts::ErrorHandler, Opts &baseOpts) {
242239
baseOpts.enabledWarnings = IGA_WARNINGS_ALL;
243240
});
244241
wGrp.defineFlag(
@@ -247,7 +244,7 @@ extern "C" int iga_main(int argc, const char **argv)
247244
"uses default warnings",
248245
nullptr,
249246
opts::OptAttrs::ALLOW_UNSET,
250-
[] (const char *cinp, const opts::ErrorHandler err, Opts &baseOpts) {
247+
[] (const char *, const opts::ErrorHandler, Opts &baseOpts) {
251248
baseOpts.enabledWarnings = IGA_WARNINGS_DEFAULT;
252249
});
253250
wGrp.defineFlag(
@@ -256,7 +253,7 @@ extern "C" int iga_main(int argc, const char **argv)
256253
"checks some don't-care fields for being in normal forms",
257254
"examples of this are types and regions on send operands",
258255
opts::OptAttrs::ALLOW_UNSET,
259-
[] (const char *cinp, const opts::ErrorHandler err, Opts &baseOpts) {
256+
[] (const char *, const opts::ErrorHandler, Opts &baseOpts) {
260257
baseOpts.enabledWarnings |= IGA_WARNINGS_NORMFORM;
261258
});
262259
wGrp.defineFlag(
@@ -265,7 +262,7 @@ extern "C" int iga_main(int argc, const char **argv)
265262
"enables warnings on invalid regions",
266263
nullptr,
267264
opts::OptAttrs::ALLOW_UNSET,
268-
[] (const char *cinp, const opts::ErrorHandler err, Opts &baseOpts) {
265+
[] (const char *, const opts::ErrorHandler, Opts &baseOpts) {
269266
baseOpts.enabledWarnings |= IGA_WARNINGS_REGIONS;
270267
});
271268
wGrp.defineFlag(
@@ -274,7 +271,7 @@ extern "C" int iga_main(int argc, const char **argv)
274271
"enables warnings on invalid operand type combinations",
275272
nullptr,
276273
opts::OptAttrs::ALLOW_UNSET,
277-
[] (const char *cinp, const opts::ErrorHandler err, Opts &baseOpts) {
274+
[] (const char *, const opts::ErrorHandler, Opts &baseOpts) {
278275
baseOpts.enabledWarnings |= IGA_WARNINGS_TYPES;
279276
});
280277
wGrp.defineFlag(
@@ -283,7 +280,7 @@ extern "C" int iga_main(int argc, const char **argv)
283280
"enables warnings related to scheduling (e.g. use of Switch)",
284281
nullptr,
285282
opts::OptAttrs::ALLOW_UNSET,
286-
[] (const char *cinp, const opts::ErrorHandler err, Opts &baseOpts) {
283+
[] (const char *, const opts::ErrorHandler, Opts &baseOpts) {
287284
baseOpts.enabledWarnings |= IGA_WARNINGS_SCHED;
288285
});
289286

@@ -298,10 +295,10 @@ extern "C" int iga_main(int argc, const char **argv)
298295
"disables the IR checking on assembly",
299296
nullptr,
300297
opts::OptAttrs::ALLOW_UNSET,
301-
[] (const char *cinp, const opts::ErrorHandler err, Opts &baseOpts) {
298+
[] (const char *, const opts::ErrorHandler, Opts &baseOpts) {
302299
baseOpts.enabledWarnings = IGA_WARNINGS_NONE;
303-
fprintf(stderr, "%s\n",
304-
"-Xdisable-ir-checking is deprecated; use -W* options");
300+
std::cerr <<
301+
"-Xdisable-ir-checking is deprecated; use -W* options\n";
305302
});
306303
xGrp.defineFlag(
307304
"auto-deps",
@@ -330,7 +327,7 @@ extern "C" int iga_main(int argc, const char **argv)
330327
"This mode debugs an instruction's compaction. The input format is the same as -Xifs\n"
331328
"See that option for more information\n",
332329
opts::OptAttrs::ALLOW_UNSET,
333-
[] (const char *, const opts::ErrorHandler &eh, Opts &baseOpts) {
330+
[] (const char *, const opts::ErrorHandler &, Opts &baseOpts) {
334331
baseOpts.mode = Opts::Mode::XDCMP;
335332
});
336333
xGrp.defineFlag(
@@ -473,7 +470,7 @@ extern "C" int iga_main(int argc, const char **argv)
473470
"number of sbid being used on auto dependency set",
474471
"",
475472
opts::OptAttrs::ALLOW_UNSET,
476-
[] (const char *cinp, const opts::ErrorHandler eh, Opts &baseOpts) {
473+
[] (const char *cinp, const opts::ErrorHandler &eh, Opts &baseOpts) {
477474
std::string str = cinp;
478475
baseOpts.sbidCount = eh.parseInt(cinp);
479476
}
@@ -485,7 +482,7 @@ extern "C" int iga_main(int argc, const char **argv)
485482
"By default we fail if we are unable to compact an instruction with "
486483
"the {Compacted} option set; this allows one to make it a warning",
487484
opts::OptAttrs::ALLOW_UNSET,
488-
[] (const char *, const opts::ErrorHandler &eh, Opts &baseOpts) {
485+
[] (const char *, const opts::ErrorHandler &, Opts &baseOpts) {
489486
baseOpts.errorOnCompactFail = false;
490487
});
491488

@@ -495,7 +492,7 @@ extern "C" int iga_main(int argc, const char **argv)
495492
"the input files",
496493
"The input files to assemble. This defaults to stdin.",
497494
opts::OptAttrs::ALLOW_UNSET | opts::OptAttrs::ALLOW_MULTI,
498-
[] (const char *inp, const opts::ErrorHandler &eh, Opts &baseOpts) {
495+
[] (const char *inp, const opts::ErrorHandler &, Opts &baseOpts) {
499496
baseOpts.inputFiles.push_back(inp);
500497
});
501498

0 commit comments

Comments
 (0)