[a32b204] | 1 | //
|
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
|
---|
| 3 | //
|
---|
| 4 | // The contents of this file are covered under the licence agreement in the
|
---|
| 5 | // file "LICENCE" distributed with Cforall.
|
---|
| 6 | //
|
---|
[a436947] | 7 | // ConversionCost.cc --
|
---|
[a32b204] | 8 | //
|
---|
| 9 | // Author : Richard C. Bilson
|
---|
| 10 | // Created On : Sun May 17 07:06:19 2015
|
---|
[fb2bde4] | 11 | // Last Modified By : Andrew Beach
|
---|
[1d17939] | 12 | // Last Modified On : Wed Jul 29 16:11:00 2020
|
---|
[cf32116] | 13 | // Update Count : 28
|
---|
[a32b204] | 14 | //
|
---|
[51b73452] | 15 |
|
---|
| 16 | #include "ConversionCost.h"
|
---|
[ea6332d] | 17 |
|
---|
| 18 | #include <cassert> // for assert
|
---|
| 19 | #include <list> // for list, list<>::const_iterator
|
---|
| 20 | #include <string> // for operator==, string
|
---|
| 21 |
|
---|
| 22 | #include "ResolvExpr/Cost.h" // for Cost
|
---|
[5bf3976] | 23 | #include "ResolvExpr/Unify.h" // for typesCompatibleIgnoreQualifiers
|
---|
| 24 | #include "ResolvExpr/PtrsAssignable.hpp" // for ptrsAssignable
|
---|
[ef1da0e2] | 25 |
|
---|
[51b73452] | 26 | namespace ResolvExpr {
|
---|
[b46e3bd] | 27 |
|
---|
[5ccb10d] | 28 | #if 0
|
---|
| 29 | #define PRINT(x) x
|
---|
| 30 | #else
|
---|
| 31 | #define PRINT(x)
|
---|
| 32 | #endif
|
---|
[ada4575] | 33 |
|
---|
[e15853c] | 34 | // GENERATED START, DO NOT EDIT
|
---|
[6fd1955] | 35 | // GENERATED BY BasicTypes-gen.cc
|
---|
[cdcddfe1] | 36 | /* EXTENDED INTEGRAL RANK HIERARCHY (root to leaves)
|
---|
[e15853c] | 37 | _Bool
|
---|
[7870799] | 38 | char signed char unsigned char
|
---|
| 39 | signed short int unsigned short int
|
---|
| 40 | signed int unsigned int
|
---|
| 41 | signed long int unsigned long int
|
---|
| 42 | signed long long int unsigned long long int
|
---|
| 43 | __int128 unsigned __int128
|
---|
| 44 | _Float16 _Float16 _Complex
|
---|
| 45 | _Float32 _Float32 _Complex
|
---|
| 46 | float float _Complex
|
---|
| 47 | _Float32x _Float32x _Complex
|
---|
| 48 | _Float64 _Float64 _Complex
|
---|
| 49 | double double _Complex
|
---|
| 50 | _Float64x _Float64x _Complex
|
---|
[e15853c] | 51 | __float80
|
---|
[7870799] | 52 | _Float128 _Float128 _Complex
|
---|
[e15853c] | 53 | __float128
|
---|
[7870799] | 54 | long double long double _Complex
|
---|
| 55 | _Float128x _Float128x _Complex
|
---|
[cdcddfe1] | 56 | */
|
---|
[e15853c] | 57 | // GENERATED END
|
---|
[cdcddfe1] | 58 |
|
---|
[e15853c] | 59 | // GENERATED START, DO NOT EDIT
|
---|
[6fd1955] | 60 | // GENERATED BY BasicTypes-gen.cc
|
---|
[7d55e4d] | 61 | static const int costMatrix[ast::BasicType::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node
|
---|
[3a55d9f] | 62 | /* B C SC UC SI SUI I UI LI LUI LLI LLUI IB UIB _FH _FH _F _FC F FC _FX _FXC FD _FDC D DC F80X_FDXC F80 _FB_FLDC FB LD LDC _FBX_FLDXC */
|
---|
| 63 | /* B */ { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 17, 16, 18, 17, },
|
---|
| 64 | /* C */ { -1, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, },
|
---|
| 65 | /* SC */ { -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, },
|
---|
| 66 | /* UC */ { -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, },
|
---|
| 67 | /* SI */ { -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 14, 16, 15, },
|
---|
| 68 | /* SUI */ { -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 14, 16, 15, },
|
---|
| 69 | /* I */ { -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 13, 15, 14, },
|
---|
| 70 | /* UI */ { -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 13, 15, 14, },
|
---|
| 71 | /* LI */ { -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 12, 14, 13, },
|
---|
| 72 | /* LUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 12, 14, 13, },
|
---|
| 73 | /* LLI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 11, 13, 12, },
|
---|
| 74 | /* LLUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 11, 13, 12, },
|
---|
| 75 | /* IB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 10, 12, 11, },
|
---|
| 76 | /* UIB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 10, 12, 11, },
|
---|
| 77 | /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 10, 9, 11, 10, },
|
---|
| 78 | /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, -1, 7, -1, -1, 8, -1, 9, },
|
---|
| 79 | /* _F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 8, 10, 9, },
|
---|
| 80 | /* _FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, -1, 6, -1, -1, 7, -1, 8, },
|
---|
| 81 | /* F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 7, 9, 8, },
|
---|
| 82 | /* FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, -1, 5, -1, -1, 6, -1, 7, },
|
---|
| 83 | /* _FX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 6, 8, 7, },
|
---|
| 84 | /* _FXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, -1, 4, -1, -1, 5, -1, 6, },
|
---|
| 85 | /* FD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 5, 7, 6, },
|
---|
| 86 | /* _FDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, -1, 3, -1, -1, 4, -1, 5, },
|
---|
| 87 | /* D */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 5, 4, 6, 5, },
|
---|
| 88 | /* DC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, -1, 2, -1, -1, 3, -1, 4, },
|
---|
| 89 | /* F80X */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 4, 3, 5, 4, },
|
---|
| 90 | /* _FDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 1, -1, -1, 2, -1, 3, },
|
---|
| 91 | /* F80 */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0, 1, 2, 2, 3, 3, 4, 4, },
|
---|
| 92 | /* _FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, },
|
---|
| 93 | /* _FLDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 1, -1, 2, },
|
---|
| 94 | /* FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0, 1, 2, 2, 3, },
|
---|
| 95 | /* LD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, },
|
---|
| 96 | /* LDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, },
|
---|
| 97 | /* _FBX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, },
|
---|
[ef5b828] | 98 | /* _FLDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, },
|
---|
[e15853c] | 99 | }; // costMatrix
|
---|
[1c9568f0] | 100 | static const int maxIntCost = 15;
|
---|
[e15853c] | 101 | // GENERATED END
|
---|
[cdcddfe1] | 102 | static_assert(
|
---|
[4ac402d] | 103 | sizeof(costMatrix)/sizeof(costMatrix[0][0]) == ast::BasicType::NUMBER_OF_BASIC_TYPES * ast::BasicType::NUMBER_OF_BASIC_TYPES,
|
---|
[cdcddfe1] | 104 | "Missing row in the cost matrix"
|
---|
| 105 | );
|
---|
| 106 |
|
---|
[e15853c] | 107 | // GENERATED START, DO NOT EDIT
|
---|
[6fd1955] | 108 | // GENERATED BY BasicTypes-gen.cc
|
---|
[7d55e4d] | 109 | static const int signMatrix[ast::BasicType::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion
|
---|
[3a55d9f] | 110 | /* B C SC UC SI SUI I UI LI LUI LLI LLUI IB UIB _FH _FH _F _FC F FC _FX _FXC FD _FDC D DC F80X_FDXC F80 _FB_FLDC FB LD LDC _FBX_FLDXC */
|
---|
| 111 | /* B */ { 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 112 | /* C */ { -1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 113 | /* SC */ { -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 114 | /* UC */ { -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 115 | /* SI */ { -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 116 | /* SUI */ { -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 117 | /* I */ { -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 118 | /* UI */ { -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 119 | /* LI */ { -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 120 | /* LUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 121 | /* LLI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 122 | /* LLUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 123 | /* IB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 124 | /* UIB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 125 | /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 126 | /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
|
---|
| 127 | /* _F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 128 | /* _FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
|
---|
| 129 | /* F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 130 | /* FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
|
---|
| 131 | /* _FX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 132 | /* _FXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
|
---|
| 133 | /* FD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 134 | /* _FDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
|
---|
| 135 | /* D */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 136 | /* DC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
|
---|
| 137 | /* F80X */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 138 | /* _FDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
|
---|
| 139 | /* F80 */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 140 | /* _FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, },
|
---|
| 141 | /* _FLDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 0, -1, 0, },
|
---|
| 142 | /* FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, },
|
---|
| 143 | /* LD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, },
|
---|
| 144 | /* LDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, },
|
---|
| 145 | /* _FBX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, },
|
---|
[ef5b828] | 146 | /* _FLDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, },
|
---|
[e15853c] | 147 | }; // signMatrix
|
---|
| 148 | // GENERATED END
|
---|
[cdcddfe1] | 149 | static_assert(
|
---|
[4ac402d] | 150 | sizeof(signMatrix)/sizeof(signMatrix[0][0]) == ast::BasicType::NUMBER_OF_BASIC_TYPES * ast::BasicType::NUMBER_OF_BASIC_TYPES,
|
---|
[cdcddfe1] | 151 | "Missing row in the sign matrix"
|
---|
| 152 | );
|
---|
[a32b204] | 153 |
|
---|
[cf32116] | 154 | namespace {
|
---|
| 155 | int localPtrsAssignable(const ast::Type * t1, const ast::Type * t2,
|
---|
| 156 | const ast::SymbolTable &, const ast::TypeEnvironment & env ) {
|
---|
| 157 | return ptrsAssignable( t1, t2, env );
|
---|
| 158 | }
|
---|
[fb2bde4] | 159 | }
|
---|
| 160 |
|
---|
| 161 | Cost conversionCost(
|
---|
[cf32116] | 162 | const ast::Type * src, const ast::Type * dst, bool srcIsLvalue,
|
---|
| 163 | const ast::SymbolTable & symtab, const ast::TypeEnvironment & env
|
---|
[fb2bde4] | 164 | ) {
|
---|
| 165 | if ( const ast::TypeInstType * inst = dynamic_cast< const ast::TypeInstType * >( dst ) ) {
|
---|
[3e5dd913] | 166 | if ( const ast::EqvClass * eqv = env.lookup( *inst ) ) {
|
---|
[fb2bde4] | 167 | if ( eqv->bound ) {
|
---|
[cf32116] | 168 | return conversionCost(src, eqv->bound, srcIsLvalue, symtab, env );
|
---|
[fb2bde4] | 169 | } else {
|
---|
| 170 | return Cost::infinity;
|
---|
| 171 | }
|
---|
| 172 | } else if ( const ast::NamedTypeDecl * named = symtab.lookupType( inst->name ) ) {
|
---|
| 173 | const ast::TypeDecl * type = dynamic_cast< const ast::TypeDecl * >( named );
|
---|
| 174 | assertf( type, "Unexpected typedef." );
|
---|
| 175 | if ( type->base ) {
|
---|
[cf32116] | 176 | return conversionCost( src, type->base, srcIsLvalue, symtab, env ) + Cost::safe;
|
---|
[fb2bde4] | 177 | }
|
---|
| 178 | }
|
---|
| 179 | }
|
---|
[251ce80] | 180 | if ( typesCompatibleIgnoreQualifiers( src, dst, env ) ) {
|
---|
[9d5089e] | 181 | return Cost::zero;
|
---|
[fb2bde4] | 182 | } else if ( dynamic_cast< const ast::VoidType * >( dst ) ) {
|
---|
| 183 | return Cost::safe;
|
---|
| 184 | } else if ( const ast::ReferenceType * refType =
|
---|
| 185 | dynamic_cast< const ast::ReferenceType * >( dst ) ) {
|
---|
[cf32116] | 186 | return convertToReferenceCost( src, refType, srcIsLvalue, symtab, env, localPtrsAssignable );
|
---|
[fb2bde4] | 187 | } else {
|
---|
[0bd3faf] | 188 | return ast::Pass<ConversionCost>::read( src, dst, srcIsLvalue, symtab, env, conversionCost );
|
---|
[fb2bde4] | 189 | }
|
---|
| 190 | }
|
---|
| 191 |
|
---|
[cf32116] | 192 | static Cost convertToReferenceCost( const ast::Type * src, const ast::Type * dst, bool srcIsLvalue,
|
---|
[0f19f5e5] | 193 | int diff, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env,
|
---|
[cf32116] | 194 | PtrsCalculation func ) {
|
---|
[fb2bde4] | 195 | if ( 0 < diff ) {
|
---|
| 196 | Cost cost = convertToReferenceCost(
|
---|
[cf32116] | 197 | strict_dynamic_cast< const ast::ReferenceType * >( src )->base, dst,
|
---|
| 198 | srcIsLvalue, (diff - 1), symtab, env, func );
|
---|
[fb2bde4] | 199 | cost.incReference();
|
---|
| 200 | return cost;
|
---|
| 201 | } else if ( diff < -1 ) {
|
---|
| 202 | Cost cost = convertToReferenceCost(
|
---|
| 203 | src, strict_dynamic_cast< const ast::ReferenceType * >( dst )->base,
|
---|
[cf32116] | 204 | srcIsLvalue, (diff + 1), symtab, env, func );
|
---|
[fb2bde4] | 205 | cost.incReference();
|
---|
| 206 | return cost;
|
---|
| 207 | } else if ( 0 == diff ) {
|
---|
| 208 | const ast::ReferenceType * srcAsRef = dynamic_cast< const ast::ReferenceType * >( src );
|
---|
| 209 | const ast::ReferenceType * dstAsRef = dynamic_cast< const ast::ReferenceType * >( dst );
|
---|
| 210 | if ( srcAsRef && dstAsRef ) {
|
---|
| 211 | ast::CV::Qualifiers tq1 = srcAsRef->base->qualifiers;
|
---|
| 212 | ast::CV::Qualifiers tq2 = dstAsRef->base->qualifiers;
|
---|
| 213 | if ( tq1 <= tq2 && typesCompatibleIgnoreQualifiers(
|
---|
[251ce80] | 214 | srcAsRef->base, dstAsRef->base, env ) ) {
|
---|
[fb2bde4] | 215 | if ( tq1 == tq2 ) {
|
---|
| 216 | return Cost::zero;
|
---|
| 217 | } else {
|
---|
| 218 | return Cost::safe;
|
---|
| 219 | }
|
---|
| 220 | } else {
|
---|
| 221 | int assignResult = func( srcAsRef->base, dstAsRef->base, symtab, env );
|
---|
| 222 | if ( 0 < assignResult ) {
|
---|
| 223 | return Cost::safe;
|
---|
| 224 | } else if ( assignResult < 0 ) {
|
---|
| 225 | return Cost::unsafe;
|
---|
| 226 | }
|
---|
| 227 | }
|
---|
| 228 | } else {
|
---|
[0bd3faf] | 229 | return ast::Pass<ConversionCost>::read( src, dst, srcIsLvalue, symtab, env, conversionCost );
|
---|
[fb2bde4] | 230 | }
|
---|
| 231 | } else {
|
---|
| 232 | assert( -1 == diff );
|
---|
| 233 | const ast::ReferenceType * dstAsRef = dynamic_cast< const ast::ReferenceType * >( dst );
|
---|
| 234 | assert( dstAsRef );
|
---|
[251ce80] | 235 | if ( typesCompatibleIgnoreQualifiers( src, dstAsRef->base, env ) ) {
|
---|
[cf32116] | 236 | if ( srcIsLvalue ) {
|
---|
[fb2bde4] | 237 | if ( src->qualifiers == dstAsRef->base->qualifiers ) {
|
---|
| 238 | return Cost::reference;
|
---|
| 239 | } else if ( src->qualifiers < dstAsRef->base->qualifiers ) {
|
---|
| 240 | return Cost::safe;
|
---|
| 241 | } else {
|
---|
| 242 | return Cost::unsafe;
|
---|
| 243 | }
|
---|
| 244 | } else if ( dstAsRef->base->is_const() ) {
|
---|
| 245 | return Cost::safe;
|
---|
| 246 | } else {
|
---|
| 247 | return Cost::unsafe;
|
---|
| 248 | }
|
---|
| 249 | }
|
---|
| 250 | }
|
---|
| 251 | return Cost::infinity;
|
---|
| 252 | }
|
---|
| 253 |
|
---|
| 254 | Cost convertToReferenceCost( const ast::Type * src, const ast::ReferenceType * dst,
|
---|
[cf32116] | 255 | bool srcIsLvalue, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env,
|
---|
| 256 | PtrsCalculation func ) {
|
---|
[fb2bde4] | 257 | int sdepth = src->referenceDepth(), ddepth = dst->referenceDepth();
|
---|
[cf32116] | 258 | return convertToReferenceCost( src, dst, srcIsLvalue, sdepth - ddepth, symtab, env, func );
|
---|
[fb2bde4] | 259 | }
|
---|
| 260 |
|
---|
[0bd3faf] | 261 | void ConversionCost::postvisit( const ast::VoidType * voidType ) {
|
---|
[fb2bde4] | 262 | (void)voidType;
|
---|
| 263 | cost = Cost::infinity;
|
---|
| 264 | }
|
---|
| 265 |
|
---|
[0bd3faf] | 266 | void ConversionCost::conversionCostFromBasicToBasic( const ast::BasicType * src, const ast::BasicType* dest ) {
|
---|
[fc134a48] | 267 | int tableResult = costMatrix[ src->kind ][ dest->kind ];
|
---|
| 268 | if ( tableResult == -1 ) {
|
---|
| 269 | cost = Cost::unsafe;
|
---|
| 270 | } else {
|
---|
| 271 | cost = Cost::zero;
|
---|
| 272 | cost.incSafe( tableResult );
|
---|
| 273 | cost.incSign( signMatrix[ src->kind ][ dest->kind ] );
|
---|
| 274 | }
|
---|
| 275 | }
|
---|
| 276 |
|
---|
[0bd3faf] | 277 | void ConversionCost::postvisit( const ast::BasicType * basicType ) {
|
---|
[fb2bde4] | 278 | if ( const ast::BasicType * dstAsBasic = dynamic_cast< const ast::BasicType * >( dst ) ) {
|
---|
[fc134a48] | 279 | conversionCostFromBasicToBasic( basicType, dstAsBasic );
|
---|
| 280 | } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) {
|
---|
| 281 | const ast::EnumDecl * enumDecl = enumInst->base.get();
|
---|
[b0d9ff7] | 282 | if ( enumDecl->isTyped && !enumDecl->base.get() ) {
|
---|
[0bd3faf] | 283 | cost = Cost::infinity;
|
---|
[b0d9ff7] | 284 | } else if ( const ast::Type * enumType = enumDecl->base.get() ) {
|
---|
[fc134a48] | 285 | if ( const ast::BasicType * enumTypeAsBasic = dynamic_cast<const ast::BasicType *>(enumType) ) {
|
---|
| 286 | conversionCostFromBasicToBasic( basicType, enumTypeAsBasic );
|
---|
| 287 | } else {
|
---|
| 288 | cost = Cost::infinity;
|
---|
| 289 | }
|
---|
[fb2bde4] | 290 | } else {
|
---|
[fc134a48] | 291 | cost = Cost::unsafe;
|
---|
[fb2bde4] | 292 | }
|
---|
| 293 | }
|
---|
| 294 | }
|
---|
| 295 |
|
---|
[0bd3faf] | 296 | void ConversionCost::postvisit( const ast::PointerType * pointerType ) {
|
---|
[fb2bde4] | 297 | if ( const ast::PointerType * dstAsPtr = dynamic_cast< const ast::PointerType * >( dst ) ) {
|
---|
| 298 | ast::CV::Qualifiers tq1 = pointerType->base->qualifiers;
|
---|
| 299 | ast::CV::Qualifiers tq2 = dstAsPtr->base->qualifiers;
|
---|
| 300 | if ( tq1 <= tq2 && typesCompatibleIgnoreQualifiers(
|
---|
[251ce80] | 301 | pointerType->base, dstAsPtr->base, env ) ) {
|
---|
[fb2bde4] | 302 | if ( tq1 == tq2 ) {
|
---|
| 303 | cost = Cost::zero;
|
---|
| 304 | } else {
|
---|
| 305 | cost = Cost::safe;
|
---|
| 306 | }
|
---|
[ef1da0e2] | 307 | }
|
---|
| 308 | /*
|
---|
| 309 | else if ( const ast::FunctionType * dstFunc = dstAsPtr->base.as<ast::FunctionType>()) {
|
---|
| 310 | if (const ast::FunctionType * srcFunc = pointerType->base.as<ast::FunctionType>()) {
|
---|
| 311 | if (dstFunc->params.empty() && dstFunc->isVarArgs ) {
|
---|
| 312 | cost = Cost::unsafe; // assign any function to variadic fptr
|
---|
| 313 | }
|
---|
| 314 | }
|
---|
| 315 | else {
|
---|
| 316 | ast::AssertionSet need, have; // unused
|
---|
| 317 | ast::OpenVarSet open;
|
---|
| 318 | env.extractOpenVars(open);
|
---|
| 319 | ast::TypeEnvironment tenv = env;
|
---|
| 320 | if ( unify(dstAsPtr->base, pointerType->base, tenv, need, have, open, symtab) ) {
|
---|
| 321 | cost = Cost::safe;
|
---|
| 322 | }
|
---|
| 323 | }
|
---|
| 324 | // else infinity
|
---|
| 325 | }
|
---|
| 326 | */
|
---|
| 327 | else {
|
---|
[fb2bde4] | 328 | int assignResult = ptrsAssignable( pointerType->base, dstAsPtr->base, env );
|
---|
| 329 | if ( 0 < assignResult && tq1 <= tq2 ) {
|
---|
| 330 | if ( tq1 == tq2 ) {
|
---|
| 331 | cost = Cost::safe;
|
---|
| 332 | } else {
|
---|
| 333 | cost = Cost::safe + Cost::safe;
|
---|
| 334 | }
|
---|
| 335 | } else if ( assignResult < 0 ) {
|
---|
| 336 | cost = Cost::unsafe;
|
---|
| 337 | } // else Cost::infinity
|
---|
| 338 | }
|
---|
| 339 | }
|
---|
| 340 | }
|
---|
| 341 |
|
---|
[0bd3faf] | 342 | void ConversionCost::postvisit( const ast::ArrayType * arrayType ) {
|
---|
[fb2bde4] | 343 | (void)arrayType;
|
---|
| 344 | }
|
---|
| 345 |
|
---|
[0bd3faf] | 346 | void ConversionCost::postvisit( const ast::ReferenceType * refType ) {
|
---|
[fb2bde4] | 347 | assert( nullptr == dynamic_cast< const ast::ReferenceType * >( dst ) );
|
---|
| 348 |
|
---|
[cf32116] | 349 | cost = costCalc( refType->base, dst, srcIsLvalue, symtab, env );
|
---|
[46da46b] | 350 |
|
---|
| 351 | // xxx - should qualifiers be considered in pass-by-value?
|
---|
| 352 | /*
|
---|
[fb2bde4] | 353 | if ( refType->base->qualifiers == dst->qualifiers ) {
|
---|
| 354 | cost.incReference();
|
---|
| 355 | } else if ( refType->base->qualifiers < dst->qualifiers ) {
|
---|
| 356 | cost.incSafe();
|
---|
| 357 | } else {
|
---|
| 358 | cost.incUnsafe();
|
---|
| 359 | }
|
---|
[46da46b] | 360 | */
|
---|
| 361 | cost.incReference();
|
---|
[fb2bde4] | 362 | }
|
---|
| 363 |
|
---|
[0bd3faf] | 364 | void ConversionCost::postvisit( const ast::FunctionType * functionType ) {
|
---|
[fb2bde4] | 365 | (void)functionType;
|
---|
| 366 | }
|
---|
| 367 |
|
---|
[0bd3faf] | 368 | void ConversionCost::postvisit( const ast::EnumInstType * enumInstType ) {
|
---|
[fc134a48] | 369 | const ast::EnumDecl * baseEnum = enumInstType->base;
|
---|
| 370 | if ( const ast::Type * baseType = baseEnum->base ) {
|
---|
[b0d9ff7] | 371 | costCalc( baseType, dst, srcIsLvalue, symtab, env );
|
---|
[fc134a48] | 372 | } else {
|
---|
| 373 | static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
|
---|
| 374 | cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
|
---|
| 375 | }
|
---|
[fb2bde4] | 376 | if ( cost < Cost::unsafe ) {
|
---|
| 377 | cost.incSafe();
|
---|
| 378 | }
|
---|
| 379 | }
|
---|
| 380 |
|
---|
[0bd3faf] | 381 | void ConversionCost::postvisit( const ast::TraitInstType * traitInstType ) {
|
---|
[fb2bde4] | 382 | (void)traitInstType;
|
---|
| 383 | }
|
---|
| 384 |
|
---|
[0bd3faf] | 385 | void ConversionCost::postvisit( const ast::TypeInstType * typeInstType ) {
|
---|
[3e5dd913] | 386 | if ( const ast::EqvClass * eqv = env.lookup( *typeInstType ) ) {
|
---|
[cf32116] | 387 | cost = costCalc( eqv->bound, dst, srcIsLvalue, symtab, env );
|
---|
[fb2bde4] | 388 | } else if ( const ast::TypeInstType * dstAsInst =
|
---|
| 389 | dynamic_cast< const ast::TypeInstType * >( dst ) ) {
|
---|
[3e5dd913] | 390 | if ( *typeInstType == *dstAsInst ) {
|
---|
[fb2bde4] | 391 | cost = Cost::zero;
|
---|
| 392 | }
|
---|
| 393 | } else if ( const ast::NamedTypeDecl * namedType = symtab.lookupType( typeInstType->name ) ) {
|
---|
| 394 | const ast::TypeDecl * type = dynamic_cast< const ast::TypeDecl * >( namedType );
|
---|
| 395 | assertf( type, "Unexpected typedef.");
|
---|
| 396 | if ( type->base ) {
|
---|
[cf32116] | 397 | cost = costCalc( type->base, dst, srcIsLvalue, symtab, env ) + Cost::safe;
|
---|
[fb2bde4] | 398 | }
|
---|
| 399 | }
|
---|
| 400 | }
|
---|
| 401 |
|
---|
[0bd3faf] | 402 | void ConversionCost::postvisit( const ast::TupleType * tupleType ) {
|
---|
[fb2bde4] | 403 | Cost c = Cost::zero;
|
---|
| 404 | if ( const ast::TupleType * dstAsTuple = dynamic_cast< const ast::TupleType * >( dst ) ) {
|
---|
| 405 | auto srcIt = tupleType->types.begin();
|
---|
| 406 | auto dstIt = dstAsTuple->types.begin();
|
---|
| 407 | auto srcEnd = tupleType->types.end();
|
---|
| 408 | auto dstEnd = dstAsTuple->types.end();
|
---|
| 409 | while ( srcIt != srcEnd && dstIt != dstEnd ) {
|
---|
[cf32116] | 410 | Cost newCost = costCalc( * srcIt++, * dstIt++, srcIsLvalue, symtab, env );
|
---|
[fb2bde4] | 411 | if ( newCost == Cost::infinity ) {
|
---|
| 412 | return;
|
---|
| 413 | }
|
---|
| 414 | c += newCost;
|
---|
| 415 | }
|
---|
| 416 | if ( dstIt != dstEnd ) {
|
---|
| 417 | cost = Cost::infinity;
|
---|
| 418 | } else {
|
---|
| 419 | cost = c;
|
---|
| 420 | }
|
---|
| 421 | }
|
---|
| 422 | }
|
---|
| 423 |
|
---|
[0bd3faf] | 424 | void ConversionCost::postvisit( const ast::VarArgsType * varArgsType ) {
|
---|
[fb2bde4] | 425 | (void)varArgsType;
|
---|
| 426 | if ( dynamic_cast< const ast::VarArgsType * >( dst ) ) {
|
---|
| 427 | cost = Cost::zero;
|
---|
| 428 | }
|
---|
| 429 | }
|
---|
| 430 |
|
---|
[0bd3faf] | 431 | void ConversionCost::postvisit( const ast::ZeroType * zeroType ) {
|
---|
[fb2bde4] | 432 | (void)zeroType;
|
---|
| 433 | if ( dynamic_cast< const ast::ZeroType * >( dst ) ) {
|
---|
| 434 | cost = Cost::zero;
|
---|
| 435 | } else if ( const ast::BasicType * dstAsBasic =
|
---|
| 436 | dynamic_cast< const ast::BasicType * >( dst ) ) {
|
---|
| 437 | int tableResult = costMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ];
|
---|
| 438 | if ( -1 == tableResult ) {
|
---|
| 439 | cost = Cost::unsafe;
|
---|
| 440 | } else {
|
---|
| 441 | cost = Cost::zero;
|
---|
| 442 | cost.incSafe( tableResult + 1 );
|
---|
| 443 | cost.incSign( signMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ] );
|
---|
| 444 | }
|
---|
[46da46b] | 445 | // this has the effect of letting any expr such as x+0, x+1 to be typed
|
---|
| 446 | // the same as x, instead of at least int. are we willing to sacrifice this little
|
---|
| 447 | // bit of coherence with C?
|
---|
| 448 | // TODO: currently this does not work when no zero/one overloads exist. Find a fix for it.
|
---|
| 449 | // cost = Cost::zero;
|
---|
[2f98fb2] | 450 | } else if ( dynamic_cast< const ast::PointerType * >( dst ) ) {
|
---|
| 451 | cost = Cost::zero;
|
---|
| 452 | // +1 for zero_t ->, +1 for disambiguation
|
---|
| 453 | cost.incSafe( maxIntCost + 2 );
|
---|
[46da46b] | 454 | // assuming 0p is supposed to be used for pointers?
|
---|
[fb2bde4] | 455 | }
|
---|
| 456 | }
|
---|
| 457 |
|
---|
[0bd3faf] | 458 | void ConversionCost::postvisit( const ast::OneType * oneType ) {
|
---|
[fb2bde4] | 459 | (void)oneType;
|
---|
| 460 | if ( dynamic_cast< const ast::OneType * >( dst ) ) {
|
---|
| 461 | cost = Cost::zero;
|
---|
| 462 | } else if ( const ast::BasicType * dstAsBasic =
|
---|
[0bd3faf] | 463 | dynamic_cast< const ast::BasicType * >( dst ) ) {
|
---|
[fb2bde4] | 464 | int tableResult = costMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ];
|
---|
| 465 | if ( -1 == tableResult ) {
|
---|
| 466 | cost = Cost::unsafe;
|
---|
| 467 | } else {
|
---|
| 468 | cost = Cost::zero;
|
---|
| 469 | cost.incSafe( tableResult + 1 );
|
---|
| 470 | cost.incSign( signMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ] );
|
---|
| 471 | }
|
---|
[9d5089e] | 472 | }
|
---|
[fb2bde4] | 473 | }
|
---|
[0bd3faf] | 474 |
|
---|
| 475 | // size_t ConversionCost::traceId = Stats::Heap::new_stacktrace_id("ConversionCost");
|
---|
[fb2bde4] | 476 |
|
---|
[51b73452] | 477 | } // namespace ResolvExpr
|
---|
[a32b204] | 478 |
|
---|
| 479 | // Local Variables: //
|
---|
| 480 | // tab-width: 4 //
|
---|
| 481 | // mode: c++ //
|
---|
| 482 | // compile-command: "make install" //
|
---|
| 483 | // End: //
|
---|