003 File Manager
Current Path:
/usr/src/contrib/llvm-project/clang/lib/AST/Interp
usr
/
src
/
contrib
/
llvm-project
/
clang
/
lib
/
AST
/
Interp
/
📁
..
📄
Boolean.h
(4.12 KB)
📄
ByteCodeEmitter.cpp
(5.38 KB)
📄
ByteCodeEmitter.h
(3.13 KB)
📄
ByteCodeExprGen.cpp
(16.6 KB)
📄
ByteCodeExprGen.h
(10.2 KB)
📄
ByteCodeGenError.cpp
(483 B)
📄
ByteCodeGenError.h
(1.36 KB)
📄
ByteCodeStmtGen.cpp
(7.21 KB)
📄
ByteCodeStmtGen.h
(2.39 KB)
📄
Context.cpp
(3.28 KB)
📄
Context.h
(2.39 KB)
📄
Descriptor.cpp
(10.31 KB)
📄
Descriptor.h
(7.82 KB)
📄
Disasm.cpp
(1.95 KB)
📄
EvalEmitter.cpp
(7.6 KB)
📄
EvalEmitter.h
(3.7 KB)
📄
Frame.cpp
(464 B)
📄
Frame.h
(1.28 KB)
📄
Function.cpp
(1.73 KB)
📄
Function.h
(4.91 KB)
📄
Integral.h
(8.38 KB)
📄
Interp.cpp
(11.54 KB)
📄
Interp.h
(30.64 KB)
📄
InterpBlock.cpp
(1.91 KB)
📄
InterpBlock.h
(4.11 KB)
📄
InterpFrame.cpp
(5.32 KB)
📄
InterpFrame.h
(4.54 KB)
📄
InterpStack.cpp
(1.81 KB)
📄
InterpStack.h
(3.43 KB)
📄
InterpState.cpp
(2.03 KB)
📄
InterpState.h
(3.29 KB)
📄
Opcode.h
(817 B)
📄
Opcodes.td
(11.02 KB)
📄
Pointer.cpp
(4.97 KB)
📄
Pointer.h
(11.08 KB)
📄
PrimType.cpp
(648 B)
📄
PrimType.h
(4.66 KB)
📄
Program.cpp
(11.29 KB)
📄
Program.h
(6.66 KB)
📄
Record.cpp
(1.54 KB)
📄
Record.h
(3.76 KB)
📄
Source.cpp
(1.15 KB)
📄
Source.h
(3.25 KB)
📄
State.cpp
(5.34 KB)
📄
State.h
(4.01 KB)
Editing: Function.h
//===--- Function.h - Bytecode function for the VM --------------*- C++ -*-===// // // 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 // //===----------------------------------------------------------------------===// // // Defines the Function class which holds all bytecode function-specific data. // // The scope class which describes local variables is also defined here. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_AST_INTERP_FUNCTION_H #define LLVM_CLANG_AST_INTERP_FUNCTION_H #include "Pointer.h" #include "Source.h" #include "clang/AST/Decl.h" #include "llvm/Support/raw_ostream.h" namespace clang { namespace interp { class Program; class ByteCodeEmitter; enum PrimType : uint32_t; /// Describes a scope block. /// /// The block gathers all the descriptors of the locals defined in this block. class Scope { public: /// Information about a local's storage. struct Local { /// Offset of the local in frame. unsigned Offset; /// Descriptor of the local. Descriptor *Desc; }; using LocalVectorTy = llvm::SmallVector<Local, 8>; Scope(LocalVectorTy &&Descriptors) : Descriptors(std::move(Descriptors)) {} llvm::iterator_range<LocalVectorTy::iterator> locals() { return llvm::make_range(Descriptors.begin(), Descriptors.end()); } private: /// Object descriptors in this block. LocalVectorTy Descriptors; }; /// Bytecode function. /// /// Contains links to the bytecode of the function, as well as metadata /// describing all arguments and stack-local variables. class Function { public: using ParamDescriptor = std::pair<PrimType, Descriptor *>; /// Returns the size of the function's local stack. unsigned getFrameSize() const { return FrameSize; } /// Returns the size of the argument stackx unsigned getArgSize() const { return ArgSize; } /// Returns a pointer to the start of the code. CodePtr getCodeBegin() const; /// Returns a pointer to the end of the code. CodePtr getCodeEnd() const; /// Returns the original FunctionDecl. const FunctionDecl *getDecl() const { return F; } /// Returns the lcoation. SourceLocation getLoc() const { return Loc; } /// Returns a parameter descriptor. ParamDescriptor getParamDescriptor(unsigned Offset) const; /// Checks if the first argument is a RVO pointer. bool hasRVO() const { return ParamTypes.size() != Params.size(); } /// Range over the scope blocks. llvm::iterator_range<llvm::SmallVector<Scope, 2>::iterator> scopes() { return llvm::make_range(Scopes.begin(), Scopes.end()); } /// Range over argument types. using arg_reverse_iterator = SmallVectorImpl<PrimType>::reverse_iterator; llvm::iterator_range<arg_reverse_iterator> args_reverse() { return llvm::make_range(ParamTypes.rbegin(), ParamTypes.rend()); } /// Returns a specific scope. Scope &getScope(unsigned Idx) { return Scopes[Idx]; } /// Returns the source information at a given PC. SourceInfo getSource(CodePtr PC) const; /// Checks if the function is valid to call in constexpr. bool isConstexpr() const { return IsValid; } /// Checks if the function is virtual. bool isVirtual() const; /// Checks if the function is a constructor. bool isConstructor() const { return isa<CXXConstructorDecl>(F); } private: /// Construct a function representing an actual function. Function(Program &P, const FunctionDecl *F, unsigned ArgSize, llvm::SmallVector<PrimType, 8> &&ParamTypes, llvm::DenseMap<unsigned, ParamDescriptor> &&Params); /// Sets the code of a function. void setCode(unsigned NewFrameSize, std::vector<char> &&NewCode, SourceMap &&NewSrcMap, llvm::SmallVector<Scope, 2> &&NewScopes) { FrameSize = NewFrameSize; Code = std::move(NewCode); SrcMap = std::move(NewSrcMap); Scopes = std::move(NewScopes); IsValid = true; } private: friend class Program; friend class ByteCodeEmitter; /// Program reference. Program &P; /// Location of the executed code. SourceLocation Loc; /// Declaration this function was compiled from. const FunctionDecl *F; /// Local area size: storage + metadata. unsigned FrameSize; /// Size of the argument stack. unsigned ArgSize; /// Program code. std::vector<char> Code; /// Opcode-to-expression mapping. SourceMap SrcMap; /// List of block descriptors. llvm::SmallVector<Scope, 2> Scopes; /// List of argument types. llvm::SmallVector<PrimType, 8> ParamTypes; /// Map from byte offset to parameter descriptor. llvm::DenseMap<unsigned, ParamDescriptor> Params; /// Flag to indicate if the function is valid. bool IsValid = false; public: /// Dumps the disassembled bytecode to \c llvm::errs(). void dump() const; void dump(llvm::raw_ostream &OS) const; }; } // namespace interp } // namespace clang #endif
Upload File
Create Folder