1*700637cbSDimitry Andric //===------ Primitives.h - Types for the constexpr VM -----------*- C++ -*-===// 2*700637cbSDimitry Andric // 3*700637cbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*700637cbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*700637cbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*700637cbSDimitry Andric // 7*700637cbSDimitry Andric //===----------------------------------------------------------------------===// 8*700637cbSDimitry Andric // 9*700637cbSDimitry Andric // Utilities and helper functions for all primitive types: 10*700637cbSDimitry Andric // - Integral 11*700637cbSDimitry Andric // - Floating 12*700637cbSDimitry Andric // - Boolean 13*700637cbSDimitry Andric // 14*700637cbSDimitry Andric //===----------------------------------------------------------------------===// 15*700637cbSDimitry Andric 16*700637cbSDimitry Andric #ifndef LLVM_CLANG_AST_INTERP_PRIMITIVES_H 17*700637cbSDimitry Andric #define LLVM_CLANG_AST_INTERP_PRIMITIVES_H 18*700637cbSDimitry Andric 19*700637cbSDimitry Andric #include "clang/AST/ComparisonCategories.h" 20*700637cbSDimitry Andric 21*700637cbSDimitry Andric namespace clang { 22*700637cbSDimitry Andric namespace interp { 23*700637cbSDimitry Andric 24*700637cbSDimitry Andric /// Helper to compare two comparable types. Compare(const T & X,const T & Y)25*700637cbSDimitry Andrictemplate <typename T> ComparisonCategoryResult Compare(const T &X, const T &Y) { 26*700637cbSDimitry Andric if (X < Y) 27*700637cbSDimitry Andric return ComparisonCategoryResult::Less; 28*700637cbSDimitry Andric if (X > Y) 29*700637cbSDimitry Andric return ComparisonCategoryResult::Greater; 30*700637cbSDimitry Andric return ComparisonCategoryResult::Equal; 31*700637cbSDimitry Andric } 32*700637cbSDimitry Andric 33*700637cbSDimitry Andric } // namespace interp 34*700637cbSDimitry Andric } // namespace clang 35*700637cbSDimitry Andric 36*700637cbSDimitry Andric #endif 37