LLVM  13.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 using namespace llvm;
13 
14 /// The ScalableErrorAsWarning is a temporary measure to suppress errors from
15 /// using the wrong interface on a scalable vector.
17  "treat-scalable-fixed-error-as-warning", cl::Hidden, cl::init(false),
18  cl::desc("Treat issues where a fixed-width property is requested from a "
19  "scalable type as a warning, instead of an error."),
21 
22 void llvm::reportInvalidSizeRequest(const char *Msg) {
23 #ifndef STRICT_FIXED_SIZE_VECTORS
25  WithColor::warning() << "Invalid size request on a scalable vector; " << Msg
26  << "\n";
27  return;
28  }
29 #endif
30  report_fatal_error("Invalid size request on a scalable vector.");
31 }
32 
33 TypeSize::operator TypeSize::ScalarTy() const {
34  if (isScalable()) {
36  "Cannot implicitly convert a scalable size to a fixed-width size in "
37  "`TypeSize::operator ScalarTy()`");
38  return getKnownMinValue();
39  }
40  return getFixedValue();
41 }
llvm
Definition: AllocatorList.h:23
TypeSize.h
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
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::report_fatal_error
LLVM_ATTRIBUTE_NORETURN 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:63
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::LinearPolySize< TypeSize >::getFixedValue
ScalarTy getFixedValue() const
Definition: TypeSize.h:313
ScalableErrorAsWarning
cl::opt< bool > ScalableErrorAsWarning("treat-scalable-fixed-error-as-warning", cl::Hidden, cl::init(false), cl::desc("Treat issues where a fixed-width property is requested from a " "scalable type as a warning, instead of an error."), cl::ZeroOrMore)
The ScalableErrorAsWarning is a temporary measure to suppress errors from using the wrong interface o...
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:22