[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 | # warning For overload resolution between the two versions.
|
---|
| 156 | int localPtrsAssignable(const ast::Type * t1, const ast::Type * t2,
|
---|
| 157 | const ast::SymbolTable &, const ast::TypeEnvironment & env ) {
|
---|
| 158 | return ptrsAssignable( t1, t2, env );
|
---|
| 159 | }
|
---|
| 160 | Cost localConversionCost(
|
---|
| 161 | const ast::Type * src, const ast::Type * dst, bool srcIsLvalue,
|
---|
| 162 | const ast::SymbolTable & symtab, const ast::TypeEnvironment & env
|
---|
| 163 | ) { return conversionCost( src, dst, srcIsLvalue, symtab, env ); }
|
---|
[fb2bde4] | 164 | }
|
---|
| 165 |
|
---|
| 166 | Cost conversionCost(
|
---|
[cf32116] | 167 | const ast::Type * src, const ast::Type * dst, bool srcIsLvalue,
|
---|
| 168 | const ast::SymbolTable & symtab, const ast::TypeEnvironment & env
|
---|
[fb2bde4] | 169 | ) {
|
---|
| 170 | if ( const ast::TypeInstType * inst = dynamic_cast< const ast::TypeInstType * >( dst ) ) {
|
---|
[3e5dd913] | 171 | if ( const ast::EqvClass * eqv = env.lookup( *inst ) ) {
|
---|
[fb2bde4] | 172 | if ( eqv->bound ) {
|
---|
[cf32116] | 173 | return conversionCost(src, eqv->bound, srcIsLvalue, symtab, env );
|
---|
[fb2bde4] | 174 | } else {
|
---|
| 175 | return Cost::infinity;
|
---|
| 176 | }
|
---|
| 177 | } else if ( const ast::NamedTypeDecl * named = symtab.lookupType( inst->name ) ) {
|
---|
| 178 | const ast::TypeDecl * type = dynamic_cast< const ast::TypeDecl * >( named );
|
---|
| 179 | assertf( type, "Unexpected typedef." );
|
---|
| 180 | if ( type->base ) {
|
---|
[cf32116] | 181 | return conversionCost( src, type->base, srcIsLvalue, symtab, env ) + Cost::safe;
|
---|
[fb2bde4] | 182 | }
|
---|
| 183 | }
|
---|
| 184 | }
|
---|
[251ce80] | 185 | if ( typesCompatibleIgnoreQualifiers( src, dst, env ) ) {
|
---|
[9d5089e] | 186 | return Cost::zero;
|
---|
[fb2bde4] | 187 | } else if ( dynamic_cast< const ast::VoidType * >( dst ) ) {
|
---|
| 188 | return Cost::safe;
|
---|
| 189 | } else if ( const ast::ReferenceType * refType =
|
---|
| 190 | dynamic_cast< const ast::ReferenceType * >( dst ) ) {
|
---|
[cf32116] | 191 | return convertToReferenceCost( src, refType, srcIsLvalue, symtab, env, localPtrsAssignable );
|
---|
[fb2bde4] | 192 | } else {
|
---|
[e6b42e7] | 193 | return ast::Pass<ConversionCost_new>::read( src, dst, srcIsLvalue, symtab, env, localConversionCost );
|
---|
[fb2bde4] | 194 | }
|
---|
| 195 | }
|
---|
| 196 |
|
---|
[cf32116] | 197 | static Cost convertToReferenceCost( const ast::Type * src, const ast::Type * dst, bool srcIsLvalue,
|
---|
[0f19f5e5] | 198 | int diff, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env,
|
---|
[cf32116] | 199 | PtrsCalculation func ) {
|
---|
[fb2bde4] | 200 | if ( 0 < diff ) {
|
---|
| 201 | Cost cost = convertToReferenceCost(
|
---|
[cf32116] | 202 | strict_dynamic_cast< const ast::ReferenceType * >( src )->base, dst,
|
---|
| 203 | srcIsLvalue, (diff - 1), symtab, env, func );
|
---|
[fb2bde4] | 204 | cost.incReference();
|
---|
| 205 | return cost;
|
---|
| 206 | } else if ( diff < -1 ) {
|
---|
| 207 | Cost cost = convertToReferenceCost(
|
---|
| 208 | src, strict_dynamic_cast< const ast::ReferenceType * >( dst )->base,
|
---|
[cf32116] | 209 | srcIsLvalue, (diff + 1), symtab, env, func );
|
---|
[fb2bde4] | 210 | cost.incReference();
|
---|
| 211 | return cost;
|
---|
| 212 | } else if ( 0 == diff ) {
|
---|
| 213 | const ast::ReferenceType * srcAsRef = dynamic_cast< const ast::ReferenceType * >( src );
|
---|
| 214 | const ast::ReferenceType * dstAsRef = dynamic_cast< const ast::ReferenceType * >( dst );
|
---|
| 215 | if ( srcAsRef && dstAsRef ) {
|
---|
| 216 | ast::CV::Qualifiers tq1 = srcAsRef->base->qualifiers;
|
---|
| 217 | ast::CV::Qualifiers tq2 = dstAsRef->base->qualifiers;
|
---|
| 218 | if ( tq1 <= tq2 && typesCompatibleIgnoreQualifiers(
|
---|
[251ce80] | 219 | srcAsRef->base, dstAsRef->base, env ) ) {
|
---|
[fb2bde4] | 220 | if ( tq1 == tq2 ) {
|
---|
| 221 | return Cost::zero;
|
---|
| 222 | } else {
|
---|
| 223 | return Cost::safe;
|
---|
| 224 | }
|
---|
| 225 | } else {
|
---|
| 226 | int assignResult = func( srcAsRef->base, dstAsRef->base, symtab, env );
|
---|
| 227 | if ( 0 < assignResult ) {
|
---|
| 228 | return Cost::safe;
|
---|
| 229 | } else if ( assignResult < 0 ) {
|
---|
| 230 | return Cost::unsafe;
|
---|
| 231 | }
|
---|
| 232 | }
|
---|
| 233 | } else {
|
---|
[e6b42e7] | 234 | return ast::Pass<ConversionCost_new>::read( src, dst, srcIsLvalue, symtab, env, localConversionCost );
|
---|
[fb2bde4] | 235 | }
|
---|
| 236 | } else {
|
---|
| 237 | assert( -1 == diff );
|
---|
| 238 | const ast::ReferenceType * dstAsRef = dynamic_cast< const ast::ReferenceType * >( dst );
|
---|
| 239 | assert( dstAsRef );
|
---|
[251ce80] | 240 | if ( typesCompatibleIgnoreQualifiers( src, dstAsRef->base, env ) ) {
|
---|
[cf32116] | 241 | if ( srcIsLvalue ) {
|
---|
[fb2bde4] | 242 | if ( src->qualifiers == dstAsRef->base->qualifiers ) {
|
---|
| 243 | return Cost::reference;
|
---|
| 244 | } else if ( src->qualifiers < dstAsRef->base->qualifiers ) {
|
---|
| 245 | return Cost::safe;
|
---|
| 246 | } else {
|
---|
| 247 | return Cost::unsafe;
|
---|
| 248 | }
|
---|
| 249 | } else if ( dstAsRef->base->is_const() ) {
|
---|
| 250 | return Cost::safe;
|
---|
| 251 | } else {
|
---|
| 252 | return Cost::unsafe;
|
---|
| 253 | }
|
---|
| 254 | }
|
---|
| 255 | }
|
---|
| 256 | return Cost::infinity;
|
---|
| 257 | }
|
---|
| 258 |
|
---|
| 259 | Cost convertToReferenceCost( const ast::Type * src, const ast::ReferenceType * dst,
|
---|
[cf32116] | 260 | bool srcIsLvalue, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env,
|
---|
| 261 | PtrsCalculation func ) {
|
---|
[fb2bde4] | 262 | int sdepth = src->referenceDepth(), ddepth = dst->referenceDepth();
|
---|
[cf32116] | 263 | return convertToReferenceCost( src, dst, srcIsLvalue, sdepth - ddepth, symtab, env, func );
|
---|
[fb2bde4] | 264 | }
|
---|
| 265 |
|
---|
| 266 | void ConversionCost_new::postvisit( const ast::VoidType * voidType ) {
|
---|
| 267 | (void)voidType;
|
---|
| 268 | cost = Cost::infinity;
|
---|
| 269 | }
|
---|
| 270 |
|
---|
[fc134a48] | 271 | void ConversionCost_new::conversionCostFromBasicToBasic( const ast::BasicType * src, const ast::BasicType* dest ) {
|
---|
| 272 | int tableResult = costMatrix[ src->kind ][ dest->kind ];
|
---|
| 273 | if ( tableResult == -1 ) {
|
---|
| 274 | cost = Cost::unsafe;
|
---|
| 275 | } else {
|
---|
| 276 | cost = Cost::zero;
|
---|
| 277 | cost.incSafe( tableResult );
|
---|
| 278 | cost.incSign( signMatrix[ src->kind ][ dest->kind ] );
|
---|
| 279 | }
|
---|
| 280 | }
|
---|
| 281 |
|
---|
[fb2bde4] | 282 | void ConversionCost_new::postvisit( const ast::BasicType * basicType ) {
|
---|
| 283 | if ( const ast::BasicType * dstAsBasic = dynamic_cast< const ast::BasicType * >( dst ) ) {
|
---|
[fc134a48] | 284 | conversionCostFromBasicToBasic( basicType, dstAsBasic );
|
---|
| 285 | } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) {
|
---|
| 286 | const ast::EnumDecl * enumDecl = enumInst->base.get();
|
---|
[b0d9ff7] | 287 | if ( enumDecl->isTyped && !enumDecl->base.get() ) {
|
---|
| 288 | cost = Cost::infinity;
|
---|
| 289 | } else if ( const ast::Type * enumType = enumDecl->base.get() ) {
|
---|
[fc134a48] | 290 | if ( const ast::BasicType * enumTypeAsBasic = dynamic_cast<const ast::BasicType *>(enumType) ) {
|
---|
| 291 | conversionCostFromBasicToBasic( basicType, enumTypeAsBasic );
|
---|
| 292 | } else {
|
---|
| 293 | cost = Cost::infinity;
|
---|
| 294 | }
|
---|
[fb2bde4] | 295 | } else {
|
---|
[fc134a48] | 296 | cost = Cost::unsafe;
|
---|
[fb2bde4] | 297 | }
|
---|
| 298 | }
|
---|
| 299 | }
|
---|
| 300 |
|
---|
| 301 | void ConversionCost_new::postvisit( const ast::PointerType * pointerType ) {
|
---|
| 302 | if ( const ast::PointerType * dstAsPtr = dynamic_cast< const ast::PointerType * >( dst ) ) {
|
---|
| 303 | ast::CV::Qualifiers tq1 = pointerType->base->qualifiers;
|
---|
| 304 | ast::CV::Qualifiers tq2 = dstAsPtr->base->qualifiers;
|
---|
| 305 | if ( tq1 <= tq2 && typesCompatibleIgnoreQualifiers(
|
---|
[251ce80] | 306 | pointerType->base, dstAsPtr->base, env ) ) {
|
---|
[fb2bde4] | 307 | if ( tq1 == tq2 ) {
|
---|
| 308 | cost = Cost::zero;
|
---|
| 309 | } else {
|
---|
| 310 | cost = Cost::safe;
|
---|
| 311 | }
|
---|
[ef1da0e2] | 312 | }
|
---|
| 313 | /*
|
---|
| 314 | else if ( const ast::FunctionType * dstFunc = dstAsPtr->base.as<ast::FunctionType>()) {
|
---|
| 315 | if (const ast::FunctionType * srcFunc = pointerType->base.as<ast::FunctionType>()) {
|
---|
| 316 | if (dstFunc->params.empty() && dstFunc->isVarArgs ) {
|
---|
| 317 | cost = Cost::unsafe; // assign any function to variadic fptr
|
---|
| 318 | }
|
---|
| 319 | }
|
---|
| 320 | else {
|
---|
| 321 | ast::AssertionSet need, have; // unused
|
---|
| 322 | ast::OpenVarSet open;
|
---|
| 323 | env.extractOpenVars(open);
|
---|
| 324 | ast::TypeEnvironment tenv = env;
|
---|
| 325 | if ( unify(dstAsPtr->base, pointerType->base, tenv, need, have, open, symtab) ) {
|
---|
| 326 | cost = Cost::safe;
|
---|
| 327 | }
|
---|
| 328 | }
|
---|
| 329 | // else infinity
|
---|
| 330 | }
|
---|
| 331 | */
|
---|
| 332 | else {
|
---|
[fb2bde4] | 333 | int assignResult = ptrsAssignable( pointerType->base, dstAsPtr->base, env );
|
---|
| 334 | if ( 0 < assignResult && tq1 <= tq2 ) {
|
---|
| 335 | if ( tq1 == tq2 ) {
|
---|
| 336 | cost = Cost::safe;
|
---|
| 337 | } else {
|
---|
| 338 | cost = Cost::safe + Cost::safe;
|
---|
| 339 | }
|
---|
| 340 | } else if ( assignResult < 0 ) {
|
---|
| 341 | cost = Cost::unsafe;
|
---|
| 342 | } // else Cost::infinity
|
---|
| 343 | }
|
---|
| 344 | }
|
---|
| 345 | }
|
---|
| 346 |
|
---|
| 347 | void ConversionCost_new::postvisit( const ast::ArrayType * arrayType ) {
|
---|
| 348 | (void)arrayType;
|
---|
| 349 | }
|
---|
| 350 |
|
---|
| 351 | void ConversionCost_new::postvisit( const ast::ReferenceType * refType ) {
|
---|
| 352 | assert( nullptr == dynamic_cast< const ast::ReferenceType * >( dst ) );
|
---|
| 353 |
|
---|
[cf32116] | 354 | cost = costCalc( refType->base, dst, srcIsLvalue, symtab, env );
|
---|
[46da46b] | 355 |
|
---|
| 356 | // xxx - should qualifiers be considered in pass-by-value?
|
---|
| 357 | /*
|
---|
[fb2bde4] | 358 | if ( refType->base->qualifiers == dst->qualifiers ) {
|
---|
| 359 | cost.incReference();
|
---|
| 360 | } else if ( refType->base->qualifiers < dst->qualifiers ) {
|
---|
| 361 | cost.incSafe();
|
---|
| 362 | } else {
|
---|
| 363 | cost.incUnsafe();
|
---|
| 364 | }
|
---|
[46da46b] | 365 | */
|
---|
| 366 | cost.incReference();
|
---|
[fb2bde4] | 367 | }
|
---|
| 368 |
|
---|
| 369 | void ConversionCost_new::postvisit( const ast::FunctionType * functionType ) {
|
---|
| 370 | (void)functionType;
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 | void ConversionCost_new::postvisit( const ast::EnumInstType * enumInstType ) {
|
---|
[fc134a48] | 374 | const ast::EnumDecl * baseEnum = enumInstType->base;
|
---|
| 375 | if ( const ast::Type * baseType = baseEnum->base ) {
|
---|
[b0d9ff7] | 376 | costCalc( baseType, dst, srcIsLvalue, symtab, env );
|
---|
[fc134a48] | 377 | } else {
|
---|
| 378 | static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
|
---|
| 379 | cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
|
---|
| 380 | }
|
---|
[fb2bde4] | 381 | if ( cost < Cost::unsafe ) {
|
---|
| 382 | cost.incSafe();
|
---|
| 383 | }
|
---|
| 384 | }
|
---|
| 385 |
|
---|
| 386 | void ConversionCost_new::postvisit( const ast::TraitInstType * traitInstType ) {
|
---|
| 387 | (void)traitInstType;
|
---|
| 388 | }
|
---|
| 389 |
|
---|
| 390 | void ConversionCost_new::postvisit( const ast::TypeInstType * typeInstType ) {
|
---|
[3e5dd913] | 391 | if ( const ast::EqvClass * eqv = env.lookup( *typeInstType ) ) {
|
---|
[cf32116] | 392 | cost = costCalc( eqv->bound, dst, srcIsLvalue, symtab, env );
|
---|
[fb2bde4] | 393 | } else if ( const ast::TypeInstType * dstAsInst =
|
---|
| 394 | dynamic_cast< const ast::TypeInstType * >( dst ) ) {
|
---|
[3e5dd913] | 395 | if ( *typeInstType == *dstAsInst ) {
|
---|
[fb2bde4] | 396 | cost = Cost::zero;
|
---|
| 397 | }
|
---|
| 398 | } else if ( const ast::NamedTypeDecl * namedType = symtab.lookupType( typeInstType->name ) ) {
|
---|
| 399 | const ast::TypeDecl * type = dynamic_cast< const ast::TypeDecl * >( namedType );
|
---|
| 400 | assertf( type, "Unexpected typedef.");
|
---|
| 401 | if ( type->base ) {
|
---|
[cf32116] | 402 | cost = costCalc( type->base, dst, srcIsLvalue, symtab, env ) + Cost::safe;
|
---|
[fb2bde4] | 403 | }
|
---|
| 404 | }
|
---|
| 405 | }
|
---|
| 406 |
|
---|
| 407 | void ConversionCost_new::postvisit( const ast::TupleType * tupleType ) {
|
---|
| 408 | Cost c = Cost::zero;
|
---|
| 409 | if ( const ast::TupleType * dstAsTuple = dynamic_cast< const ast::TupleType * >( dst ) ) {
|
---|
| 410 | auto srcIt = tupleType->types.begin();
|
---|
| 411 | auto dstIt = dstAsTuple->types.begin();
|
---|
| 412 | auto srcEnd = tupleType->types.end();
|
---|
| 413 | auto dstEnd = dstAsTuple->types.end();
|
---|
| 414 | while ( srcIt != srcEnd && dstIt != dstEnd ) {
|
---|
[cf32116] | 415 | Cost newCost = costCalc( * srcIt++, * dstIt++, srcIsLvalue, symtab, env );
|
---|
[fb2bde4] | 416 | if ( newCost == Cost::infinity ) {
|
---|
| 417 | return;
|
---|
| 418 | }
|
---|
| 419 | c += newCost;
|
---|
| 420 | }
|
---|
| 421 | if ( dstIt != dstEnd ) {
|
---|
| 422 | cost = Cost::infinity;
|
---|
| 423 | } else {
|
---|
| 424 | cost = c;
|
---|
| 425 | }
|
---|
| 426 | }
|
---|
| 427 | }
|
---|
| 428 |
|
---|
| 429 | void ConversionCost_new::postvisit( const ast::VarArgsType * varArgsType ) {
|
---|
| 430 | (void)varArgsType;
|
---|
| 431 | if ( dynamic_cast< const ast::VarArgsType * >( dst ) ) {
|
---|
| 432 | cost = Cost::zero;
|
---|
| 433 | }
|
---|
| 434 | }
|
---|
| 435 |
|
---|
| 436 | void ConversionCost_new::postvisit( const ast::ZeroType * zeroType ) {
|
---|
| 437 | (void)zeroType;
|
---|
| 438 | if ( dynamic_cast< const ast::ZeroType * >( dst ) ) {
|
---|
| 439 | cost = Cost::zero;
|
---|
| 440 | } else if ( const ast::BasicType * dstAsBasic =
|
---|
| 441 | dynamic_cast< const ast::BasicType * >( dst ) ) {
|
---|
| 442 | int tableResult = costMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ];
|
---|
| 443 | if ( -1 == tableResult ) {
|
---|
| 444 | cost = Cost::unsafe;
|
---|
| 445 | } else {
|
---|
| 446 | cost = Cost::zero;
|
---|
| 447 | cost.incSafe( tableResult + 1 );
|
---|
| 448 | cost.incSign( signMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ] );
|
---|
| 449 | }
|
---|
[46da46b] | 450 | // this has the effect of letting any expr such as x+0, x+1 to be typed
|
---|
| 451 | // the same as x, instead of at least int. are we willing to sacrifice this little
|
---|
| 452 | // bit of coherence with C?
|
---|
| 453 | // TODO: currently this does not work when no zero/one overloads exist. Find a fix for it.
|
---|
| 454 | // cost = Cost::zero;
|
---|
[2f98fb2] | 455 | } else if ( dynamic_cast< const ast::PointerType * >( dst ) ) {
|
---|
| 456 | cost = Cost::zero;
|
---|
| 457 | // +1 for zero_t ->, +1 for disambiguation
|
---|
| 458 | cost.incSafe( maxIntCost + 2 );
|
---|
[46da46b] | 459 | // assuming 0p is supposed to be used for pointers?
|
---|
[fb2bde4] | 460 | }
|
---|
| 461 | }
|
---|
| 462 |
|
---|
| 463 | void ConversionCost_new::postvisit( const ast::OneType * oneType ) {
|
---|
| 464 | (void)oneType;
|
---|
| 465 | if ( dynamic_cast< const ast::OneType * >( dst ) ) {
|
---|
| 466 | cost = Cost::zero;
|
---|
| 467 | } else if ( const ast::BasicType * dstAsBasic =
|
---|
[46da46b] | 468 | dynamic_cast< const ast::BasicType * >( dst ) ) {
|
---|
[fb2bde4] | 469 | int tableResult = costMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ];
|
---|
| 470 | if ( -1 == tableResult ) {
|
---|
| 471 | cost = Cost::unsafe;
|
---|
| 472 | } else {
|
---|
| 473 | cost = Cost::zero;
|
---|
| 474 | cost.incSafe( tableResult + 1 );
|
---|
| 475 | cost.incSign( signMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ] );
|
---|
| 476 | }
|
---|
[46da46b] | 477 |
|
---|
| 478 | // cost = Cost::zero;
|
---|
[9d5089e] | 479 | }
|
---|
[fb2bde4] | 480 | }
|
---|
[0d070ca] | 481 | // size_t ConversionCost_new::traceId = Stats::Heap::new_stacktrace_id("ConversionCost");
|
---|
[fb2bde4] | 482 |
|
---|
[51b73452] | 483 | } // namespace ResolvExpr
|
---|
[a32b204] | 484 |
|
---|
| 485 | // Local Variables: //
|
---|
| 486 | // tab-width: 4 //
|
---|
| 487 | // mode: c++ //
|
---|
| 488 | // compile-command: "make install" //
|
---|
| 489 | // End: //
|
---|