Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: src/IceAPFloat.h

Issue 797323002: Simplify LLVM's APInt and APFloat for use in Subzero. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/IceAPInt.h » ('j') | src/IceAPInt.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 //===-- subzero/src/IceAPFloat.h - Constant float conversions --*- C++ -*--===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief This file implements a class to represent Subzero float and double
12 /// values.
13 ///
14 /// Note: This is a simplified version of
15 /// llvm/include/llvm/ADT/APFloat.h for use with Subzero.
16 //===----------------------------------------------------------------------===//
17
18 #ifndef SUBZERO_SRC_ICEAPFLOAT_H
19 #define SUBZERO_SRC_ICEAPFLOAT_H
20
21 #include "IceAPInt.h"
22
23 namespace Ice {
24
25 /// Takes a 32-bit Int and converts it to the corresponding float value.
26 inline float convertAPIntToFloat(const APInt &Int) {
27 assert(Int.getBitWidth() == 32);
28 union {
29 uint32_t IntValue;
30 float FloatValue;
31 } Converter;
32 Converter.IntValue = static_cast<uint32_t>(Int.getRawData());
33 return Converter.FloatValue;
34 }
35
36 /// Takes a 64-bit Int and converts it to the corresponding double value.
Jim Stichnoth 2014/12/12 21:54:15 Consider reducing code duplication: template<type
Karl 2014/12/12 22:46:12 Done.
37 inline double convertAPIntToDouble(const APInt &Int) {
38 assert(Int.getBitWidth() == 64);
39 union {
40 uint64_t IntValue;
41 double DoubleValue;
42 } Converter;
43 Converter.IntValue = static_cast<uint64_t>(Int.getRawData());
44 return Converter.DoubleValue;
45 }
46
47 } // end of namespace Ice
48
49 #endif // SUBZERO_SRC_ICEAPFLOAT_H
OLDNEW
« no previous file with comments | « no previous file | src/IceAPInt.h » ('j') | src/IceAPInt.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698