mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Correct format: ``` //===--- Name of file - Description ----------------------------*- Lang -*-===// ``` Notes: * Comment line should be exactly 80 chars. * Padding: Pad with dashes after "Description" to reach 80 chars. * "Name of file", "Description" and "Lang" are all optional. * In case of missing "Lang": drop the "-*-" markers. * In case of missing space: drop one, two or three dashes before "Name of file".
53 lines
1.9 KiB
C++
53 lines
1.9 KiB
C++
//===--- ConstantFolding.h - Utilities for SIL constant folding -*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See http://swift.org/LICENSE.txt for license information
|
|
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines utility functions for constant folding.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_SIL_CONSTANTFOLDING_H
|
|
#define SWIFT_SIL_CONSTANTFOLDING_H
|
|
|
|
#include "swift/SIL/SILInstruction.h"
|
|
|
|
namespace swift {
|
|
|
|
/// Evaluates the constant result of a binary bit-operation.
|
|
///
|
|
/// The \p ID must be the ID of a binary bit-operation builtin.
|
|
APInt constantFoldBitOperation(APInt lhs, APInt rhs, BuiltinValueKind ID);
|
|
|
|
/// Evaluates the constant result of an integer comparison.
|
|
///
|
|
/// The \p ID must be the ID of an integer builtin operation.
|
|
APInt constantFoldComparison(APInt lhs, APInt rhs, BuiltinValueKind ID);
|
|
|
|
/// Evaluates the constant result of a binary operation with overflow.
|
|
///
|
|
/// The \p ID must be the ID of a binary operation with overflow.
|
|
APInt constantFoldBinaryWithOverflow(APInt lhs, APInt rhs, bool &Overflow,
|
|
llvm::Intrinsic::ID ID);
|
|
|
|
/// Evaluates the constant result of a division operation.
|
|
///
|
|
/// The \p ID must be the ID of a division operation.
|
|
APInt constantFoldDiv(APInt lhs, APInt rhs, bool &Overflow, BuiltinValueKind ID);
|
|
|
|
/// Evaluates the constant result of an integer cast operation.
|
|
///
|
|
/// The \p ID must be the ID of a trunc/sext/zext builtin.
|
|
APInt constantFoldCast(APInt val, const BuiltinInfo &BI);
|
|
|
|
} // End namespace swift.
|
|
|
|
#endif
|