LLVM 22.0.0git
AsmParserContext.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_ASMPARSER_ASMPARSERCONTEXT_H
10#define LLVM_ASMPARSER_ASMPARSERCONTEXT_H
11
12#include "llvm/ADT/DenseMap.h"
15#include "llvm/IR/Value.h"
16#include <optional>
17
18namespace llvm {
19class BasicBlock;
20
21/// Registry of file location information for LLVM IR constructs.
22///
23/// This class provides access to the file location information
24/// for various LLVM IR constructs. Currently, it supports Function,
25/// BasicBlock and Instruction locations.
26///
27/// When available, it can answer queries about what is at a given
28/// file location, as well as where in a file a given IR construct
29/// is.
30///
31/// This information is optionally emitted by the LLParser while
32/// it reads LLVM textual IR.
34 using FMap =
38
40 FMap::Allocator FAllocator;
41 FMap FunctionsInverse = FMap(FAllocator);
43 using BBMap =
47 BBMap::Allocator BBAllocator;
48 BBMap BlocksInverse = BBMap(BBAllocator);
50 using IMap =
54 IMap::Allocator IAllocator;
55 IMap InstructionsInverse = IMap(IAllocator);
56
57public:
58 LLVM_ABI std::optional<FileLocRange>
59 getFunctionLocation(const Function *) const;
60 LLVM_ABI std::optional<FileLocRange>
61 getBlockLocation(const BasicBlock *) const;
62 LLVM_ABI std::optional<FileLocRange>
64 /// Get the function at the requested location range.
65 /// If no single function occupies the queried range, or the record is
66 /// missing, a nullptr is returned.
68 /// Get the function at the requested location.
69 /// If no function occupies the queried location, or the record is missing, a
70 /// nullptr is returned.
72 /// Get the block at the requested location range.
73 /// If no single block occupies the queried range, or the record is missing, a
74 /// nullptr is returned.
76 /// Get the block at the requested location.
77 /// If no block occupies the queried location, or the record is missing, a
78 /// nullptr is returned.
80 /// Get the instruction at the requested location range.
81 /// If no single instruction occupies the queried range, or the record is
82 /// missing, a nullptr is returned.
84 /// Get the instruction at the requested location.
85 /// If no instruction occupies the queried location, or the record is missing,
86 /// a nullptr is returned.
91};
92} // namespace llvm
93
94#endif
#define LLVM_ABI
Definition Compiler.h:213
This file defines the DenseMap class.
This file implements a coalescing interval map for small objects.
Registry of file location information for LLVM IR constructs.
BasicBlock * getBlockAtLocation(const FileLocRange &) const
Get the block at the requested location range.
bool addInstructionLocation(Instruction *, const FileLocRange &)
bool addBlockLocation(BasicBlock *, const FileLocRange &)
LLVM_ABI std::optional< FileLocRange > getFunctionLocation(const Function *) const
Function * getFunctionAtLocation(const FileLocRange &) const
Get the function at the requested location range.
LLVM_ABI std::optional< FileLocRange > getInstructionLocation(const Instruction *) const
Instruction * getInstructionAtLocation(const FileLocRange &) const
Get the instruction at the requested location range.
LLVM_ABI std::optional< FileLocRange > getBlockLocation(const BasicBlock *) const
bool addFunctionLocation(Function *, const FileLocRange &)
LLVM Basic Block Representation.
Definition BasicBlock.h:62
typename Sizer::Allocator Allocator
This is an optimization pass for GlobalISel generic memory operations.
Struct holding a semiopen range [Start; End)
Definition FileLoc.h:42
Struct holding Line:Column location.
Definition FileLoc.h:18