1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00
Commit Graph

28 Commits

Author SHA1 Message Date
Eric Astor
2b759c7f74 [ms] [llvm-ml] Support built-in text macros
Add support for all built-in text macros supported by ML64:
@Date, @Time, @FileName, @FileCur, and @CurSeg.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D104965
2021-07-21 11:44:09 -04:00
Fangrui Song
47a9b3b42d [OptTable] Rename PrintHelp to printHelp
To be consistent with other member functions and match the coding standard.
2021-06-24 14:47:03 -07:00
Eric Astor
a76f35c86b [ms] [llvm-ml] Add support for INCLUDE environment variable
Also adds support for the ML.exe command-line flag /X, which ignores the INCLUDE environment variable.

This relands commit c43f413b01b021a8f7b6fce013296114fa92a245 using lit's cross-platform `env` support.

Differential Revision: https://reviews.llvm.org/D103989
2021-06-09 17:54:40 -04:00
Eric Astor
c35099a5e4 Revert "[ms] [llvm-ml] Add support for INCLUDE environment variable"
This reverts commit c43f413b01b021a8f7b6fce013296114fa92a245 due to Windows environment build breaks
2021-06-09 15:49:51 -04:00
Eric Astor
e4ec17b56e [ms] [llvm-ml] Add support for INCLUDE environment variable
Also adds support for the ML.exe command-line flag /X, which ignores the INCLUDE environment variable.
2021-06-09 15:25:26 -04:00
Philipp Krones
df7a8b162e [MC] Refactor MCObjectFileInfo initialization and allow targets to create MCObjectFileInfo
This makes it possible for targets to define their own MCObjectFileInfo.
This MCObjectFileInfo is then used to determine things like section alignment.

This is a follow up to D101462 and prepares for the RISCV backend defining the
text section alignment depending on the enabled extensions.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D101921
2021-05-23 14:15:23 -07:00
Philipp Krones
0d572a30c9 [MC] Untangle MCContext and MCObjectFileInfo
This untangles the MCContext and the MCObjectFileInfo. There is a circular
dependency between MCContext and MCObjectFileInfo. Currently this dependency
also exists during construction: You can't contruct a MOFI without a MCContext
without constructing the MCContext with a dummy version of that MOFI first.
This removes this dependency during construction. In a perfect world,
MCObjectFileInfo wouldn't depend on MCContext at all, but only be stored in the
MCContext, like other MC information. This is future work.

This also shifts/adds more information to the MCContext making it more
available to the different targets. Namely:

- TargetTriple
- ObjectFileType
- SubtargetInfo

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D101462
2021-05-05 10:03:02 -07:00
Duncan P. N. Exon Smith
ee59f57519 Support: Stop using F_{None,Text,Append} compatibility synonyms, NFC
Stop using the compatibility spellings of `OF_{None,Text,Append}`
left behind by 1f67a3cba9b09636c56e2109d8a35ae96dc15782. A follow-up
will remove them.

Differential Revision: https://reviews.llvm.org/D101650
2021-04-30 11:00:03 -07:00
Eric Astor
e5b828d67b [ms] [llvm-ml] Accept /WX to signal that warnings should be fatal.
Define -fatal-warnings to make warnings fatal, and accept /WX as an ML.EXE compatible alias for it.

Also make sure that if Warning() returns true, we always treat it as an error.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D92504
2021-04-02 15:13:20 -04:00
Eric Astor
1deec5ad2e [ms] [llvm-ml] Allow the /Zs parameter as a synonym for -filetype=null
For ml.exe, /Zs implies a syntax check with no output files.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D90061
2021-03-17 12:18:43 -04:00
Eric Astor
42660dccde [ms] [llvm-ml] Support command-line defines
Enable command-line defines as textmacros

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D90059
2020-12-01 18:06:05 -05:00
Eric Astor
4082cce59d [ms] [llvm-ml] Introduce command-line compatibility for ml.exe and ml64.exe
Switch to OptParser for command-line handling

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D90058
2020-12-01 17:43:44 -05:00
Ella Ma
59b89a3124 [llvm][clang][mlir] Add checks for the return values from Target::createXXX to prevent protential null deref
All these potential null pointer dereferences are reported by my static analyzer for null smart pointer dereferences, which has a different implementation from `alpha.cplusplus.SmartPtr`.

The checked pointers in this patch are initialized by Target::createXXX functions. When the creator function pointer is not correctly set, a null pointer will be returned, or the creator function may originally return a null pointer.

Some of them may not make sense as they may be checked before entering the function, but I fixed them all in this patch. I submit this fix because 1) similar checks are found in some other places in the LLVM codebase for the same return value of the function; and, 2) some of the pointers are dereferenced before they are checked, which may definitely trigger a null pointer dereference if the return value is nullptr.

Reviewed By: tejohnson, MaskRay, jpienaar

Differential Revision: https://reviews.llvm.org/D91410
2020-11-21 21:04:12 -08:00
Eric Astor
40fb1cd465 [ms] [llvm-ml] Lex MASM strings, including escaping
Allow single-quoted strings and double-quoted character values, as well as doubled-quote escaping.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D89731
2020-11-04 15:28:43 -05:00
Eric Astor
2259289b1f [ms] [llvm-ml] Create the @feat.00 symbol, and populate it appropriately
@feat.00 is a bitfield read by Microsoft-style linkers, and is required to signal (e.g.) /safeseh support on 32-bit systems.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D88451
2020-09-29 17:02:27 -04:00
Eric Astor
95792b92ea [ms] [llvm-ml] Add MASM hex float support
Implement MASM's syntax for specifying floats in raw hexadecimal bytes.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D87401
2020-09-29 16:57:32 -04:00
Eric Astor
ccf36de799 [ms] [llvm-ml] Add support for .radix directive, and accept all radix specifiers
Add support for .radix directive, and radix specifiers [yY] (binary), [oOqQ] (octal), and [tT] (decimal).

Also, when lexing MASM integers, require radix specifier; MASM requires that all literals without a radix specifier be treated as in the default radix. (e.g., 0100 = 100)

Relanding D87400, now with fewer ms-inline-asm tests broken!

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D88337
2020-09-29 16:55:51 -04:00
Eric Astor
6cecc11ec7 Make sure that llvm-ml uses MASM integer lexing when in --as-lex mode 2020-09-02 16:03:01 -04:00
serge-sans-paille
c884b23a0a Replace MCTargetOptionsCommandFlags.inc and CommandFlags.inc by runtime registration
MCTargetOptionsCommandFlags.inc and CommandFlags.inc are headers which contain
cl::opt with static storage.
These headers are meant to be incuded by tools to make it easier to parametrize
codegen/mc.

However, these headers are also included in at least two libraries: lldCommon
and handle-llvm. As a result, when creating DYLIB, clang-cpp holds a reference
to the options, and lldCommon holds another reference. Linking the two in a
single executable, as zig does[0], results in a double registration.

This patch explores an other approach: the .inc files are moved to regular
files, and the registration happens on-demand through static declaration of
options in the constructor of a static object.

[0] https://bugzilla.redhat.com/show_bug.cgi?id=1756977#c5

Differential Revision: https://reviews.llvm.org/D75579
2020-03-17 14:01:30 +01:00
Fangrui Song
a962b08ed4 [MC] Default MCContext::UseNamesOnTempLabels to false and only set it to true for MCAsmStreamer
Only MCAsmStreamer (assembly output) needs to keep names of temporary labels created by
MCContext::createTempSymbol().

This change made the rL236642 optimization available for cc2as and
probably some other users.

This eliminates a behavior difference between llvm-mc -filetype=obj and cc1as, which caused
https://reviews.llvm.org/D74006#1890487

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D75097
2020-02-25 18:23:10 -08:00
Eric Astor
ca668acee6 [ms] [llvm-ml] Add a draft MASM parser
Summary:
Many directives are unavailable, and support for others may be limited.

This first draft has preliminary support for:
    - conditional directives (including errors),
    - data allocation (unsigned types up to 8 bytes, and ALIGN),
    - equates/variables (numeric and text),
    - and procedure directives (without parameters),
as well as COMMENT, ECHO, INCLUDE, INCLUDELIB, PUBLIC, and EXTERN. Text variables (aka text macros) are expanded in-place wherever the identifier occurs.

We deliberately ignore all ml.exe processor directives.

Prominent features not yet supported:
    - structs
    - macros (both procedures and functions)
    - procedures (with specified parameters)
    - substitution & expansion operators

Conditional directives are complicated by the fact that "ifdef rax" is a valid way to check if a file is being assembled for a 64-bit x86 processor; we add support for "ifdef <register>" in general, which requires adding a tryParseRegister method to all MCTargetAsmParsers. (Some targets require backtracking in the non-register case.)

Reviewers: rnk, thakis

Reviewed By: thakis

Subscribers: kerbowa, merge_guards_bot, wuzish, arsenm, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, mgorny, sbc100, jgravelle-google, hiraditya, aheejin, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, Jim, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72680
2020-02-16 12:30:46 -05:00
Fangrui Song
f2049f8c24 [AsmPrinter][MCStreamer] De-capitalize EmitInstruction and EmitCFI* 2020-02-13 22:08:55 -08:00
Benjamin Kramer
87d13166c7 Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.

This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.

This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-28 23:25:25 +01:00
Eric Astor
dea61577e1 Fix build - removing legacy target reference. 2020-01-20 09:54:59 -05:00
Eric Astor
f5ab9140ce [ms] [llvm-ml] Add placeholder for llvm-ml, based on llvm-mc
As discussed on the mailing list, I plan to introduce an ml-compatible MASM assembler as part of providing more of the Windows build tools. This will be similar to llvm-mc, but with different command-line parameters.

This placeholder is purely a stripped-down version of llvm-mc; we'll eventually add support for the Microsoft-style command-line flags, and back it with a MASM parser.

Relanding this revision after fixing ARM-compatibility issues.

Reviewers: rnk, thakis, RKSimon

Reviewed By: thakis, RKSimon

Differential Revision: https://reviews.llvm.org/D72679
2020-01-20 09:19:10 -05:00
Eric Astor
538f1d9b3f Revert "[ms] [llvm-ml] Add placeholder for llvm-ml, based on llvm-mc"
This reverts commit 22af2cbefc86dbef6e11ddaa96a08956e0baf22b, due to breakages on ARM platforms.
2020-01-18 09:51:40 -05:00
Nico Weber
90a1a43a36 Remove AllTargetsAsmPrinters
It's been an empty target since r360498 and friends
(`git log --grep='Move InstPrinter files to MCTargetDesc.' llvm/lib/Target`),
but due to hwo the way these targets are structured it was silently
an empty target without anyone noticing.

No behavior change.
2020-01-17 19:04:06 -05:00
Eric Astor
ed7261e778 [ms] [llvm-ml] Add placeholder for llvm-ml, based on llvm-mc
Summary:
As discussed on the mailing list, I plan to introduce an ml-compatible MASM assembler as part of providing more of the Windows build tools. This will be similar to llvm-mc, but with different command-line parameters.

This placeholder is purely a stripped-down version of llvm-mc; we'll eventually add support for the Microsoft-style command-line flags, and back it with a MASM parser.

Reviewers: rnk, thakis

Reviewed By: thakis

Subscribers: merge_guards_bot, mgorny, jfb, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72679
2020-01-17 16:14:08 -05:00