2017-09-27 23:26:01 +00:00
|
|
|
//===- MILexer.h - Lexer for machine instructions ---------------*- C++ -*-===//
|
2015-06-22 20:37:46 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-06-22 20:37:46 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares the function that lexes the machine instruction source
|
|
|
|
// string.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_CODEGEN_MIRPARSER_MILEXER_H
|
|
|
|
#define LLVM_LIB_CODEGEN_MIRPARSER_MILEXER_H
|
|
|
|
|
2015-06-23 23:42:28 +00:00
|
|
|
#include "llvm/ADT/APSInt.h"
|
2017-06-06 11:49:48 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2017-09-27 23:26:01 +00:00
|
|
|
#include <string>
|
2015-06-22 20:37:46 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class Twine;
|
|
|
|
|
|
|
|
/// A token produced by the machine instruction lexer.
|
|
|
|
struct MIToken {
|
|
|
|
enum TokenKind {
|
|
|
|
// Markers
|
|
|
|
Eof,
|
|
|
|
Error,
|
2015-08-13 23:10:16 +00:00
|
|
|
Newline,
|
2015-06-22 20:37:46 +00:00
|
|
|
|
2015-06-23 16:35:26 +00:00
|
|
|
// Tokens with no info.
|
|
|
|
comma,
|
|
|
|
equal,
|
2015-06-24 17:34:58 +00:00
|
|
|
underscore,
|
2015-07-13 23:24:34 +00:00
|
|
|
colon,
|
2015-08-03 23:08:19 +00:00
|
|
|
coloncolon,
|
2016-07-26 21:49:34 +00:00
|
|
|
dot,
|
2015-07-22 17:58:46 +00:00
|
|
|
exclaim,
|
2015-07-28 17:28:03 +00:00
|
|
|
lparen,
|
|
|
|
rparen,
|
2015-08-14 18:57:24 +00:00
|
|
|
lbrace,
|
|
|
|
rbrace,
|
2015-08-05 22:26:15 +00:00
|
|
|
plus,
|
|
|
|
minus,
|
2016-03-08 02:00:43 +00:00
|
|
|
less,
|
|
|
|
greater,
|
2015-06-23 16:35:26 +00:00
|
|
|
|
2015-07-06 23:07:26 +00:00
|
|
|
// Keywords
|
|
|
|
kw_implicit,
|
|
|
|
kw_implicit_define,
|
2015-08-19 18:55:47 +00:00
|
|
|
kw_def,
|
2015-07-07 20:34:53 +00:00
|
|
|
kw_dead,
|
[CodeGen] Split out the notions of MI invariance and MI dereferenceability.
Summary:
An IR load can be invariant, dereferenceable, neither, or both. But
currently, MI's notion of invariance is IR-invariant &&
IR-dereferenceable.
This patch splits up the notions of invariance and dereferenceability at
the MI level. It's NFC, so adds some probably-unnecessary
"is-dereferenceable" checks, which we can remove later if desired.
Reviewers: chandlerc, tstellarAMD
Subscribers: jholewinski, arsenm, nemanjai, llvm-commits
Differential Revision: https://reviews.llvm.org/D23371
llvm-svn: 281151
2016-09-11 01:38:58 +00:00
|
|
|
kw_dereferenceable,
|
2015-07-08 21:23:34 +00:00
|
|
|
kw_killed,
|
2015-07-08 23:58:31 +00:00
|
|
|
kw_undef,
|
2015-08-14 19:07:07 +00:00
|
|
|
kw_internal,
|
2015-08-05 17:49:03 +00:00
|
|
|
kw_early_clobber,
|
2015-08-05 17:41:17 +00:00
|
|
|
kw_debug_use,
|
2017-12-12 17:53:59 +00:00
|
|
|
kw_renamable,
|
2015-08-19 19:05:34 +00:00
|
|
|
kw_tied_def,
|
2015-07-17 00:24:15 +00:00
|
|
|
kw_frame_setup,
|
2018-01-09 11:33:22 +00:00
|
|
|
kw_frame_destroy,
|
2018-05-03 00:07:56 +00:00
|
|
|
kw_nnan,
|
|
|
|
kw_ninf,
|
|
|
|
kw_nsz,
|
|
|
|
kw_arcp,
|
|
|
|
kw_contract,
|
|
|
|
kw_afn,
|
|
|
|
kw_reassoc,
|
2018-09-11 21:35:32 +00:00
|
|
|
kw_nuw,
|
|
|
|
kw_nsw,
|
|
|
|
kw_exact,
|
2020-01-10 15:31:10 +01:00
|
|
|
kw_nofpexcept,
|
2015-07-22 21:15:11 +00:00
|
|
|
kw_debug_location,
|
2020-10-14 10:47:44 +01:00
|
|
|
kw_debug_instr_number,
|
2022-09-15 11:26:57 +01:00
|
|
|
kw_dbg_instr_ref,
|
2015-08-14 21:55:58 +00:00
|
|
|
kw_cfi_same_value,
|
2015-07-23 23:09:07 +00:00
|
|
|
kw_cfi_offset,
|
2017-12-15 15:17:18 +00:00
|
|
|
kw_cfi_rel_offset,
|
2015-07-27 20:39:03 +00:00
|
|
|
kw_cfi_def_cfa_register,
|
2015-07-21 22:28:27 +00:00
|
|
|
kw_cfi_def_cfa_offset,
|
2017-12-15 15:17:18 +00:00
|
|
|
kw_cfi_adjust_cfa_offset,
|
|
|
|
kw_cfi_escape,
|
2015-07-29 18:57:23 +00:00
|
|
|
kw_cfi_def_cfa,
|
2021-06-14 06:57:58 +05:30
|
|
|
kw_cfi_llvm_def_aspace_cfa,
|
2017-12-15 15:17:18 +00:00
|
|
|
kw_cfi_register,
|
|
|
|
kw_cfi_remember_state,
|
2017-11-02 12:00:58 +00:00
|
|
|
kw_cfi_restore,
|
2017-12-15 15:17:18 +00:00
|
|
|
kw_cfi_restore_state,
|
|
|
|
kw_cfi_undefined,
|
|
|
|
kw_cfi_window_save,
|
2018-12-18 10:37:42 +00:00
|
|
|
kw_cfi_aarch64_negate_ra_sign_state,
|
2015-07-28 17:28:03 +00:00
|
|
|
kw_blockaddress,
|
2016-07-29 20:32:59 +00:00
|
|
|
kw_intrinsic,
|
2015-07-28 23:02:45 +00:00
|
|
|
kw_target_index,
|
2015-07-31 20:49:21 +00:00
|
|
|
kw_half,
|
|
|
|
kw_float,
|
|
|
|
kw_double,
|
|
|
|
kw_x86_fp80,
|
|
|
|
kw_fp128,
|
|
|
|
kw_ppc_fp128,
|
2015-08-06 00:44:07 +00:00
|
|
|
kw_target_flags,
|
2015-08-04 00:24:45 +00:00
|
|
|
kw_volatile,
|
2015-08-06 16:49:30 +00:00
|
|
|
kw_non_temporal,
|
2015-08-06 16:55:53 +00:00
|
|
|
kw_invariant,
|
2015-08-07 20:48:30 +00:00
|
|
|
kw_align,
|
2021-01-11 19:58:35 -08:00
|
|
|
kw_basealign,
|
2018-01-26 11:47:28 +00:00
|
|
|
kw_addrspace,
|
2015-08-12 20:44:16 +00:00
|
|
|
kw_stack,
|
2015-08-12 21:00:22 +00:00
|
|
|
kw_got,
|
2015-08-12 21:11:08 +00:00
|
|
|
kw_jump_table,
|
2015-08-12 20:33:26 +00:00
|
|
|
kw_constant_pool,
|
2015-08-20 00:12:57 +00:00
|
|
|
kw_call_entry,
|
2020-01-08 20:02:37 -08:00
|
|
|
kw_custom,
|
2015-08-10 23:24:42 +00:00
|
|
|
kw_liveout,
|
2015-08-13 23:10:16 +00:00
|
|
|
kw_landing_pad,
|
2021-10-07 10:38:38 +01:00
|
|
|
kw_inlineasm_br_indirect_target,
|
2020-03-20 14:06:27 -07:00
|
|
|
kw_ehfunclet_entry,
|
2015-08-13 23:10:16 +00:00
|
|
|
kw_liveins,
|
|
|
|
kw_successors,
|
2016-08-17 20:25:25 +00:00
|
|
|
kw_floatpred,
|
|
|
|
kw_intpred,
|
2019-08-13 15:34:38 +00:00
|
|
|
kw_shufflemask,
|
[x86/MIR] Implement support for pre- and post-instruction symbols, as
well as MIR parsing support for `MCSymbol` `MachineOperand`s.
The only real way to test pre- and post-instruction symbol support is to
use them in operands, so I ended up implementing that within the patch
as well. I can split out the operand support if folks really want but it
doesn't really seem worth it.
The functional implementation of pre- and post-instruction symbols is
now *completely trivial*. Two tiny bits of code in the (misnamed)
AsmPrinter. It should be completely target independent as well. We emit
these exactly the same way as we emit basic block labels. Most of the
code here is to give full dumping, MIR printing, and MIR parsing support
so that we can write useful tests.
The MIR parsing of MC symbol operands still isn't 100%, as it forces the
symbols to be non-temporary and non-local symbols with names. However,
those names often can encode most (if not all) of the special semantics
desired, and unnamed symbols seem especially annoying to serialize and
de-serialize. While this isn't perfect or full support, it seems plenty
to write tests that exercise usage of these kinds of operands.
The MIR support for pre-and post-instruction symbols was quite
straightforward. I chose to print them out in an as-if-operand syntax
similar to debug locations as this seemed the cleanest way and let me
use nice introducer tokens rather than inventing more magic punctuation
like we use for memoperands.
However, supporting MIR-based parsing of these symbols caused me to
change the design of the symbol support to allow setting arbitrary
symbols. Without this, I don't see any reasonable way to test things
with MIR.
Differential Revision: https://reviews.llvm.org/D50833
llvm-svn: 339962
2018-08-16 23:11:05 +00:00
|
|
|
kw_pre_instr_symbol,
|
|
|
|
kw_post_instr_symbol,
|
2019-11-05 10:54:50 -08:00
|
|
|
kw_heap_alloc_marker,
|
2022-09-14 10:30:25 +02:00
|
|
|
kw_pcsections,
|
KCFI sanitizer
The KCFI sanitizer, enabled with `-fsanitize=kcfi`, implements a
forward-edge control flow integrity scheme for indirect calls. It
uses a !kcfi_type metadata node to attach a type identifier for each
function and injects verification code before indirect calls.
Unlike the current CFI schemes implemented in LLVM, KCFI does not
require LTO, does not alter function references to point to a jump
table, and never breaks function address equality. KCFI is intended
to be used in low-level code, such as operating system kernels,
where the existing schemes can cause undue complications because
of the aforementioned properties. However, unlike the existing
schemes, KCFI is limited to validating only function pointers and is
not compatible with executable-only memory.
KCFI does not provide runtime support, but always traps when a
type mismatch is encountered. Users of the scheme are expected
to handle the trap. With `-fsanitize=kcfi`, Clang emits a `kcfi`
operand bundle to indirect calls, and LLVM lowers this to a
known architecture-specific sequence of instructions for each
callsite to make runtime patching easier for users who require this
functionality.
A KCFI type identifier is a 32-bit constant produced by taking the
lower half of xxHash64 from a C++ mangled typename. If a program
contains indirect calls to assembly functions, they must be
manually annotated with the expected type identifiers to prevent
errors. To make this easier, Clang generates a weak SHN_ABS
`__kcfi_typeid_<function>` symbol for each address-taken function
declaration, which can be used to annotate functions in assembly
as long as at least one C translation unit linked into the program
takes the function address. For example on AArch64, we might have
the following code:
```
.c:
int f(void);
int (*p)(void) = f;
p();
.s:
.4byte __kcfi_typeid_f
.global f
f:
...
```
Note that X86 uses a different preamble format for compatibility
with Linux kernel tooling. See the comments in
`X86AsmPrinter::emitKCFITypeId` for details.
As users of KCFI may need to locate trap locations for binary
validation and error handling, LLVM can additionally emit the
locations of traps to a `.kcfi_traps` section.
Similarly to other sanitizers, KCFI checking can be disabled for a
function with a `no_sanitize("kcfi")` function attribute.
Relands 67504c95494ff05be2a613129110c9bcf17f6c13 with a fix for
32-bit builds.
Reviewed By: nickdesaulniers, kees, joaomoreira, MaskRay
Differential Revision: https://reviews.llvm.org/D119296
2022-02-15 14:32:08 -08:00
|
|
|
kw_cfi_type,
|
2020-03-16 15:56:02 -07:00
|
|
|
kw_bbsections,
|
[Propeller] Use Fixed MBB ID instead of volatile MachineBasicBlock::Number.
Let Propeller use specialized IDs for basic blocks, instead of MBB number.
This allows optimizations not just prior to asm-printer, but throughout the entire codegen.
This patch only implements the functionality under the new `LLVM_BB_ADDR_MAP` version, but the old version is still being used. A later patch will change the used version.
####Background
Today Propeller uses machine basic block (MBB) numbers, which already exist, to map native assembly to machine IR. This is done as follows.
- Basic block addresses are captured and dumped into the `LLVM_BB_ADDR_MAP` section just before the AsmPrinter pass which writes out object files. This ensures that we have a mapping that is close to assembly.
- Profiling mapping works by taking a virtual address of an instruction and looking up the `LLVM_BB_ADDR_MAP` section to find the MBB number it corresponds to.
- While this works well today, we need to do better when we scale Propeller to target other Machine IR optimizations like spill code optimization. Register allocation happens earlier in the Machine IR pipeline and we need an annotation mechanism that is valid at that point.
- The current scheme will not work in this scenario because the MBB number of a particular basic block is not fixed and changes over the course of codegen (via renumbering, adding, and removing the basic blocks).
- In other words, the volatile MBB numbers do not provide a one-to-one correspondence throughout the lifetime of Machine IR. Profile annotation using MBB numbers is restricted to a fixed point; only valid at the exact point where it was dumped.
- Further, the object file can only be dumped before AsmPrinter and cannot be dumped at an arbitrary point in the Machine IR pass pipeline. Hence, MBB numbers are not suitable and we need something else.
####Solution
We propose using fixed unique incremental MBB IDs for basic blocks instead of volatile MBB numbers. These IDs are assigned upon the creation of machine basic blocks. We modify `MachineFunction::CreateMachineBasicBlock` to assign the fixed ID to every newly created basic block. It assigns `MachineFunction::NextMBBID` to the MBB ID and then increments it, which ensures having unique IDs.
To ensure correct profile attribution, multiple equivalent compilations must generate the same Propeller IDs. This is guaranteed as long as the MachineFunction passes run in the same order. Since the `NextBBID` variable is scoped to `MachineFunction`, interleaving of codegen for different functions won't cause any inconsistencies.
The new encoding is generated under the new version number 2 and we keep backward-compatibility with older versions.
####Impact on Size of the `LLVM_BB_ADDR_MAP` Section
Emitting the Propeller ID results in a 23% increase in the size of the `LLVM_BB_ADDR_MAP` section for the clang binary.
Reviewed By: tmsriram
Differential Revision: https://reviews.llvm.org/D100808
2022-12-06 22:37:33 -08:00
|
|
|
kw_bb_id,
|
2018-08-20 20:37:57 +00:00
|
|
|
kw_unknown_size,
|
2021-03-05 20:47:09 -08:00
|
|
|
kw_unknown_address,
|
2022-08-16 16:15:44 -07:00
|
|
|
kw_ir_block_address_taken,
|
|
|
|
kw_machine_block_address_taken,
|
2015-07-06 23:07:26 +00:00
|
|
|
|
2021-05-25 20:21:21 -04:00
|
|
|
// Metadata types.
|
|
|
|
kw_distinct,
|
|
|
|
|
2015-08-17 22:05:15 +00:00
|
|
|
// Named metadata keywords
|
|
|
|
md_tbaa,
|
2015-08-17 22:06:40 +00:00
|
|
|
md_alias_scope,
|
2015-08-17 22:08:02 +00:00
|
|
|
md_noalias,
|
2015-08-17 22:09:52 +00:00
|
|
|
md_range,
|
2017-08-23 20:31:27 +00:00
|
|
|
md_diexpr,
|
[mir] Serialize DILocation inline when not possible to use a metadata reference
Summary:
Sometimes MIR-level passes create DILocations that were not present in the
LLVM-IR. For example, it may merge two DILocations together to produce a
DILocation that points to line 0.
Previously, the address of these DILocations were printed which prevented the
MIR from being read back into LLVM. With this patch, DILocations will use
metadata references where possible and fall back on serializing them inline like so:
MOV32mr %stack.0.x.addr, 1, _, 0, _, %0, debug-location !DILocation(line: 1, scope: !15)
Reviewers: aprantl, vsk, arphaman
Reviewed By: aprantl
Subscribers: probinson, llvm-commits
Tags: #debug-info
Differential Revision: https://reviews.llvm.org/D55243
llvm-svn: 349035
2018-12-13 14:25:27 +00:00
|
|
|
md_dilocation,
|
2015-08-17 22:05:15 +00:00
|
|
|
|
2015-06-22 20:37:46 +00:00
|
|
|
// Identifier tokens
|
2015-06-23 16:35:26 +00:00
|
|
|
Identifier,
|
2015-06-23 23:42:28 +00:00
|
|
|
NamedRegister,
|
2018-03-30 18:15:54 +00:00
|
|
|
NamedVirtualRegister,
|
2015-08-13 23:10:16 +00:00
|
|
|
MachineBasicBlockLabel,
|
2015-06-26 16:46:11 +00:00
|
|
|
MachineBasicBlock,
|
2015-07-16 23:37:45 +00:00
|
|
|
StackObject,
|
|
|
|
FixedStackObject,
|
2015-06-26 22:56:48 +00:00
|
|
|
NamedGlobalValue,
|
|
|
|
GlobalValue,
|
2015-07-21 16:59:53 +00:00
|
|
|
ExternalSymbol,
|
[x86/MIR] Implement support for pre- and post-instruction symbols, as
well as MIR parsing support for `MCSymbol` `MachineOperand`s.
The only real way to test pre- and post-instruction symbol support is to
use them in operands, so I ended up implementing that within the patch
as well. I can split out the operand support if folks really want but it
doesn't really seem worth it.
The functional implementation of pre- and post-instruction symbols is
now *completely trivial*. Two tiny bits of code in the (misnamed)
AsmPrinter. It should be completely target independent as well. We emit
these exactly the same way as we emit basic block labels. Most of the
code here is to give full dumping, MIR printing, and MIR parsing support
so that we can write useful tests.
The MIR parsing of MC symbol operands still isn't 100%, as it forces the
symbols to be non-temporary and non-local symbols with names. However,
those names often can encode most (if not all) of the special semantics
desired, and unnamed symbols seem especially annoying to serialize and
de-serialize. While this isn't perfect or full support, it seems plenty
to write tests that exercise usage of these kinds of operands.
The MIR support for pre-and post-instruction symbols was quite
straightforward. I chose to print them out in an as-if-operand syntax
similar to debug locations as this seemed the cleanest way and let me
use nice introducer tokens rather than inventing more magic punctuation
like we use for memoperands.
However, supporting MIR-based parsing of these symbols caused me to
change the design of the symbol support to allow setting arbitrary
symbols. Without this, I don't see any reasonable way to test things
with MIR.
Differential Revision: https://reviews.llvm.org/D50833
llvm-svn: 339962
2018-08-16 23:11:05 +00:00
|
|
|
MCSymbol,
|
2015-06-23 23:42:28 +00:00
|
|
|
|
|
|
|
// Other tokens
|
2015-07-10 22:51:20 +00:00
|
|
|
IntegerLiteral,
|
2015-07-31 20:49:21 +00:00
|
|
|
FloatingPointLiteral,
|
2016-10-12 21:06:45 +00:00
|
|
|
HexLiteral,
|
2019-08-13 15:34:38 +00:00
|
|
|
VectorLiteral,
|
2015-07-15 23:38:35 +00:00
|
|
|
VirtualRegister,
|
2015-07-20 20:51:18 +00:00
|
|
|
ConstantPoolItem,
|
2015-07-27 22:42:41 +00:00
|
|
|
JumpTableIndex,
|
2015-07-28 17:28:03 +00:00
|
|
|
NamedIRBlock,
|
2015-07-27 22:42:41 +00:00
|
|
|
IRBlock,
|
2015-08-03 23:08:19 +00:00
|
|
|
NamedIRValue,
|
2015-08-21 21:54:12 +00:00
|
|
|
IRValue,
|
2016-03-28 18:18:46 +00:00
|
|
|
QuotedIRValue, // `<constant value>`
|
2017-07-11 22:23:00 +00:00
|
|
|
SubRegisterIndex,
|
|
|
|
StringConstant
|
2015-06-22 20:37:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2017-09-27 23:26:01 +00:00
|
|
|
TokenKind Kind = Error;
|
2015-06-22 20:37:46 +00:00
|
|
|
StringRef Range;
|
2015-08-06 23:17:42 +00:00
|
|
|
StringRef StringValue;
|
|
|
|
std::string StringValueStorage;
|
2015-06-23 23:42:28 +00:00
|
|
|
APSInt IntVal;
|
2015-06-22 20:37:46 +00:00
|
|
|
|
|
|
|
public:
|
2017-09-27 23:26:01 +00:00
|
|
|
MIToken() = default;
|
2015-08-05 17:35:55 +00:00
|
|
|
|
2015-08-06 23:17:42 +00:00
|
|
|
MIToken &reset(TokenKind Kind, StringRef Range);
|
2015-06-22 20:37:46 +00:00
|
|
|
|
2015-08-06 23:17:42 +00:00
|
|
|
MIToken &setStringValue(StringRef StrVal);
|
|
|
|
MIToken &setOwnedStringValue(std::string StrVal);
|
|
|
|
MIToken &setIntegerValue(APSInt IntVal);
|
2015-06-23 23:42:28 +00:00
|
|
|
|
2015-06-22 20:37:46 +00:00
|
|
|
TokenKind kind() const { return Kind; }
|
|
|
|
|
|
|
|
bool isError() const { return Kind == Error; }
|
|
|
|
|
2015-08-13 23:10:16 +00:00
|
|
|
bool isNewlineOrEOF() const { return Kind == Newline || Kind == Eof; }
|
|
|
|
|
|
|
|
bool isErrorOrEOF() const { return Kind == Error || Kind == Eof; }
|
|
|
|
|
2015-06-24 17:34:58 +00:00
|
|
|
bool isRegister() const {
|
2015-07-10 22:51:20 +00:00
|
|
|
return Kind == NamedRegister || Kind == underscore ||
|
2018-03-30 18:15:54 +00:00
|
|
|
Kind == NamedVirtualRegister || Kind == VirtualRegister;
|
2015-06-24 17:34:58 +00:00
|
|
|
}
|
2015-06-23 16:35:26 +00:00
|
|
|
|
2015-07-06 23:07:26 +00:00
|
|
|
bool isRegisterFlag() const {
|
2015-07-08 21:23:34 +00:00
|
|
|
return Kind == kw_implicit || Kind == kw_implicit_define ||
|
2015-08-19 18:55:47 +00:00
|
|
|
Kind == kw_def || Kind == kw_dead || Kind == kw_killed ||
|
|
|
|
Kind == kw_undef || Kind == kw_internal ||
|
2017-12-12 17:53:59 +00:00
|
|
|
Kind == kw_early_clobber || Kind == kw_debug_use ||
|
|
|
|
Kind == kw_renamable;
|
2015-07-06 23:07:26 +00:00
|
|
|
}
|
|
|
|
|
2015-08-06 16:49:30 +00:00
|
|
|
bool isMemoryOperandFlag() const {
|
2015-08-06 16:55:53 +00:00
|
|
|
return Kind == kw_volatile || Kind == kw_non_temporal ||
|
2017-07-13 02:28:54 +00:00
|
|
|
Kind == kw_dereferenceable || Kind == kw_invariant ||
|
|
|
|
Kind == StringConstant;
|
2015-08-06 16:49:30 +00:00
|
|
|
}
|
2015-08-04 00:24:45 +00:00
|
|
|
|
2015-06-22 20:37:46 +00:00
|
|
|
bool is(TokenKind K) const { return Kind == K; }
|
|
|
|
|
|
|
|
bool isNot(TokenKind K) const { return Kind != K; }
|
|
|
|
|
|
|
|
StringRef::iterator location() const { return Range.begin(); }
|
|
|
|
|
2015-08-06 23:17:42 +00:00
|
|
|
StringRef range() const { return Range; }
|
2015-07-20 20:31:01 +00:00
|
|
|
|
2015-08-05 17:35:55 +00:00
|
|
|
/// Return the token's string value.
|
2015-08-06 23:17:42 +00:00
|
|
|
StringRef stringValue() const { return StringValue; }
|
2015-07-20 20:31:01 +00:00
|
|
|
|
2015-06-23 23:42:28 +00:00
|
|
|
const APSInt &integerValue() const { return IntVal; }
|
2015-06-26 16:46:11 +00:00
|
|
|
|
|
|
|
bool hasIntegerValue() const {
|
2015-06-26 22:56:48 +00:00
|
|
|
return Kind == IntegerLiteral || Kind == MachineBasicBlock ||
|
2015-08-13 23:10:16 +00:00
|
|
|
Kind == MachineBasicBlockLabel || Kind == StackObject ||
|
|
|
|
Kind == FixedStackObject || Kind == GlobalValue ||
|
|
|
|
Kind == VirtualRegister || Kind == ConstantPoolItem ||
|
2015-08-19 23:31:05 +00:00
|
|
|
Kind == JumpTableIndex || Kind == IRBlock || Kind == IRValue;
|
2015-06-26 16:46:11 +00:00
|
|
|
}
|
2015-06-22 20:37:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Consume a single machine instruction token in the given source and return
|
|
|
|
/// the remaining source string.
|
|
|
|
StringRef lexMIToken(
|
|
|
|
StringRef Source, MIToken &Token,
|
|
|
|
function_ref<void(StringRef::iterator, const Twine &)> ErrorCallback);
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
2017-09-27 23:26:01 +00:00
|
|
|
#endif // LLVM_LIB_CODEGEN_MIRPARSER_MILEXER_H
|