Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
Function.cpp
Go to the documentation of this file.
1//===- Function.cpp - The Function class of Sandbox IR --------------------===//
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#include "llvm/SandboxIR/Function.h"
10#include "llvm/IR/Value.h"
11#include "llvm/SandboxIR/Context.h"
12
13namespacellvm::sandboxir {
14
15FunctionType *Function::getFunctionType() const{
16return cast<FunctionType>(
17Ctx.getType(cast<llvm::Function>(Val)->getFunctionType()));
18}
19
20#ifndef NDEBUG
21voidFunction::dumpNameAndArgs(raw_ostream &OS) const{
22auto *F = cast<llvm::Function>(Val);
23OS << *F->getReturnType() <<" @" <<F->getName() <<"(";
24interleave(
25F->args(),
26 [this, &OS](constllvm::Argument &LLVMArg) {
27 auto *SBArg = cast_or_null<Argument>(Ctx.getValue(&LLVMArg));
28 if (SBArg == nullptr)
29 OS <<"NULL";
30 else
31 SBArg->printAsOperand(OS);
32 },
33 [&] { OS <<", "; });
34OS <<")";
35}
36
37voidFunction::dumpOS(raw_ostream &OS) const{
38dumpNameAndArgs(OS);
39OS <<" {\n";
40auto *LLVMF = cast<llvm::Function>(Val);
41interleave(
42 *LLVMF,
43 [this, &OS](constllvm::BasicBlock &LLVMBB) {
44auto *BB = cast_or_null<BasicBlock>(Ctx.getValue(&LLVMBB));
45if (BB ==nullptr)
46OS <<"NULL";
47else
48OS << *BB;
49 },
50 [&OS] {OS <<"\n"; });
51OS <<"}\n";
52}
53#endif// NDEBUG
54
55}// namespace llvm::sandboxir
Value.h
F
#define F(x, y, z)
Definition:MD5.cpp:55
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
Context.h
Function.h
llvm::Argument
This class represents an incoming formal argument to a Function.
Definition:Argument.h:31
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:BasicBlock.h:61
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
llvm::sandboxir::Context::getValue
sandboxir::Value * getValue(llvm::Value *V) const
Definition:Context.cpp:601
llvm::sandboxir::Context::getType
Type * getType(llvm::Type *LLVMTy)
Definition:Context.h:239
llvm::sandboxir::FunctionType
Definition:Type.h:450
llvm::sandboxir::Function::getFunctionType
FunctionType * getFunctionType() const
Definition:Function.cpp:15
llvm::sandboxir::Function::dumpOS
void dumpOS(raw_ostream &OS) const final
Definition:Function.cpp:37
llvm::sandboxir::Function::dumpNameAndArgs
void dumpNameAndArgs(raw_ostream &OS) const
Definition:Function.cpp:21
llvm::sandboxir::Value::Val
llvm::Value * Val
The LLVM Value that corresponds to this SandboxIR Value.
Definition:Value.h:103
llvm::sandboxir::Value::Ctx
Context & Ctx
All values point to the context.
Definition:Value.h:173
llvm::sandboxir
Definition:Argument.h:15
llvm::interleave
void interleave(ForwardIterator begin, ForwardIterator end, UnaryFunctor each_fn, NullaryFunctor between_fn)
An STL-style algorithm similar to std::for_each that applies a second functor between every pair of e...
Definition:STLExtras.h:2169

Generated on Thu Jul 17 2025 12:29:32 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp