clang 24.0.0git
LoopAttributes.h
Go to the documentation of this file.
1//===--- LoopAttributes.h - Shared loop hint state ---------------*- C++
2//-*-===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9//
10// This file holds the state of the attributes and hints that may be specified
11// on a loop, and the logic to determine it from the loop's statement
12// attributes and the command line options. Both classic CodeGen and CIR
13// CodeGen use it, and each translates the state into its own representation.
14//
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_CLANG_CODEGENUTILS_LOOPATTRIBUTES_H
18#define LLVM_CLANG_CODEGENUTILS_LOOPATTRIBUTES_H
19
20#include "llvm/ADT/ArrayRef.h"
21
22namespace clang {
23class ASTContext;
24class Attr;
25class CodeGenOptions;
26} // namespace clang
27
28namespace clang::CodeGenUtils {
29
30/// Attributes that may be specified on loops.
32 explicit LoopAttributes(bool IsParallel = false);
33 void clear();
34
35 /// Generate llvm.loop.parallel metadata for loads and stores.
37
38 /// State of loop vectorization or unrolling.
40
41 /// Value for llvm.loop.vectorize.enable metadata.
43
44 /// Value for llvm.loop.unroll.* metadata (enable, disable, or full).
46
47 /// Value for llvm.loop.unroll_and_jam.* metadata (enable, disable, or full).
49
50 /// Value for llvm.loop.vectorize.predicate metadata
52
53 /// Value for llvm.loop.vectorize.width metadata.
55
56 // Value for llvm.loop.vectorize.scalable.enable
58
59 /// Value for llvm.loop.interleave.count metadata.
61
62 /// llvm.unroll.
63 unsigned UnrollCount;
64
65 /// llvm.unroll.
67
68 /// Value for llvm.loop.distribute.enable metadata.
70
71 /// Value for llvm.loop.pipeline.disable metadata.
73
74 /// Value for llvm.licm.disable metadata.
76
77 /// Value for llvm.loop.pipeline.iicount metadata.
79
80 /// Value for 'llvm.loop.align' metadata.
81 unsigned CodeAlign;
82
83 /// Value for whether the loop is required to make progress.
85};
86
87/// Update \p Attrs with the loop hints in \p StmtAttrs (`#pragma clang loop`,
88/// `#pragma unroll`, `[[clang::code_align]]`, the OpenCL and HLSL spellings),
89/// the command line options that adjust every loop (-falign-loops and
90/// -fno-unroll-loops), and whether the loop must make progress.
92 const CodeGenOptions &CGOpts,
94 bool MustProgress);
95
96} // namespace clang::CodeGenUtils
97
98#endif // LLVM_CLANG_CODEGENUTILS_LOOPATTRIBUTES_H
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:245
Attr - This represents one attribute.
Definition Attr.h:46
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
void updateLoopAttributes(LoopAttributes &Attrs, ASTContext &Ctx, const CodeGenOptions &CGOpts, llvm::ArrayRef< const Attr * > StmtAttrs, bool MustProgress)
Update Attrs with the loop hints in StmtAttrs (#pragma clang loop, #pragma unroll,...
Top level wrappers for InstallAPI frontend operations.
Attributes that may be specified on loops.
bool LICMDisabled
Value for llvm.licm.disable metadata.
LVEnableState VectorizeEnable
Value for llvm.loop.vectorize.enable metadata.
LVEnableState UnrollEnable
Value for llvm.loop.unroll.* metadata (enable, disable, or full).
unsigned PipelineInitiationInterval
Value for llvm.loop.pipeline.iicount metadata.
unsigned UnrollAndJamCount
llvm.unroll.
LoopAttributes(bool IsParallel=false)
unsigned CodeAlign
Value for 'llvm.loop.align' metadata.
unsigned VectorizeWidth
Value for llvm.loop.vectorize.width metadata.
LVEnableState UnrollAndJamEnable
Value for llvm.loop.unroll_and_jam.* metadata (enable, disable, or full).
LVEnableState VectorizePredicateEnable
Value for llvm.loop.vectorize.predicate metadata.
bool PipelineDisabled
Value for llvm.loop.pipeline.disable metadata.
bool IsParallel
Generate llvm.loop.parallel metadata for loads and stores.
LVEnableState
State of loop vectorization or unrolling.
bool MustProgress
Value for whether the loop is required to make progress.
LVEnableState DistributeEnable
Value for llvm.loop.distribute.enable metadata.
unsigned InterleaveCount
Value for llvm.loop.interleave.count metadata.