LLVM  14.0.0git
TypeSize.cpp
Go to the documentation of this file.
1 //===- TypeSize.cpp - Wrapper around type sizes------------------*- C++ -*-===//
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 
11 
12 #include "DebugOptions.h"
13 
14 using namespace llvm;
15 
16 #ifndef STRICT_FIXED_SIZE_VECTORS
17 namespace {
18 struct CreateScalableErrorAsWarning {
19  /// The ScalableErrorAsWarning is a temporary measure to suppress errors from
20  /// using the wrong interface on a scalable vector.
21  static void *call() {
22  return new cl::opt<bool>(
23  "treat-scalable-fixed-error-as-warning", cl::Hidden, cl::init(false),
24  cl::desc(
25  "Treat issues where a fixed-width property is requested from a "
26  "scalable type as a warning, instead of an error."),
28  }
29 };
30 } // namespace
31 static ManagedStatic<cl::opt<bool>, CreateScalableErrorAsWarning>
34 #else
36 #endif
37 
38 void llvm::reportInvalidSizeRequest(const char *Msg) {
39 #ifndef STRICT_FIXED_SIZE_VECTORS
41  WithColor::warning() << "Invalid size request on a scalable vector; " << Msg
42  << "\n";
43  return;
44  }
45 #endif
46  report_fatal_error("Invalid size request on a scalable vector.");
47 }
48 
49 TypeSize::operator TypeSize::ScalarTy() const {
50  if (isScalable()) {
52  "Cannot implicitly convert a scalable size to a fixed-width size in "
53  "`TypeSize::operator ScalarTy()`");
54  return getKnownMinValue();
55  }
56  return getFixedValue();
57 }
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
TypeSize.h
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
DebugOptions.h
llvm::LinearPolySize< TypeSize >::isScalable
bool isScalable() const
Returns whether the size is scaled by a runtime quantity (vscale).
Definition: TypeSize.h:299
CommandLine.h
llvm::ManagedStatic
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
Definition: ManagedStatic.h:83
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:140
llvm::cl::ZeroOrMore
@ ZeroOrMore
Definition: CommandLine.h:120
llvm::LinearPolySize< TypeSize >::ScalarTy
typename UnivariateLinearPolyBase< TypeSize >::ScalarTy ScalarTy
Definition: TypeSize.h:272
llvm::cl::opt< bool >
llvm::WithColor::warning
static raw_ostream & warning()
Convenience method for printing "warning: " to stderr.
Definition: WithColor.cpp:77
call
S is passed via registers r2 But gcc stores them to the and then reload them to and r3 before issuing the call(r0 contains the address of the format string)
Definition: README.txt:190
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
llvm::LinearPolySize< TypeSize >::getKnownMinValue
ScalarTy getKnownMinValue() const
Returns the minimum value this size can represent.
Definition: TypeSize.h:297
llvm::initTypeSizeOptions
void initTypeSizeOptions()
Definition: TypeSize.cpp:33
llvm::LinearPolySize< TypeSize >::getFixedValue
ScalarTy getFixedValue() const
Definition: TypeSize.h:313
ScalableErrorAsWarning
static ManagedStatic< cl::opt< bool >, CreateScalableErrorAsWarning > ScalableErrorAsWarning
Definition: TypeSize.cpp:32
llvm::cl::desc
Definition: CommandLine.h:414
llvm::reportInvalidSizeRequest
void reportInvalidSizeRequest(const char *Msg)
Reports a diagnostic message to indicate an invalid size request has been done on a scalable vector.
Definition: TypeSize.cpp:38