summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGExprScalar.cpp
AgeCommit message (Collapse)Author
2020-08-24[Fixed Point] Add codegen for fixed-point shifts.Bevin Hansson
This patch adds codegen to Clang for fixed-point shift operations. Reviewed By: leonardchan Differential Revision: https://reviews.llvm.org/D83294
2020-08-24[Fixed Point] Use FixedPointBuilder to codegen fixed-point IR.Bevin Hansson
This changes the methods in CGExprScalar to use FixedPointBuilder to generate IR for fixed-point conversions and operations. Since FixedPointBuilder emits padded operations slightly differently than the original code, some tests change. Reviewed By: leonardchan Differential Revision: https://reviews.llvm.org/D86282
2020-08-20[ADT] Move FixedPoint.h from Clang to LLVM.Bevin Hansson
This patch moves FixedPointSemantics and APFixedPoint from Clang to LLVM ADT. This will make it easier to use the fixed-point classes in LLVM for constructing an IR builder for fixed-point and for reusing the APFixedPoint class for constant evaluation purposes. RFC: http://lists.llvm.org/pipermail/llvm-dev/2020-August/144025.html Reviewed By: leonardchan, rjmccall Differential Revision: https://reviews.llvm.org/D85312
2020-07-03[clang][NFC] Store a pointer to the ASTContext in ASTDumper and TextNodeDumperBruno Ricci
In general there is no way to get to the ASTContext from most AST nodes (Decls are one of the exception). This will be a problem when implementing the rest of APValue::dump since we need the ASTContext to dump some kinds of APValues. The ASTContext* in ASTDumper and TextNodeDumper is not always non-null. This is because we still want to be able to use the various dump() functions in a debugger. No functional changes intended. Reverted in fcf4d5e4499a391dff42ea1a096f146db44147b6 since a few dump() functions in lldb where missed.
2020-07-02Revert "[clang][NFC] Store a pointer to the ASTContext in ASTDumper and ↵Bruno Ricci
TextNodeDumper" This reverts commit aa7fd905e4e1bc510448431da9310e8cf5197523. I missed some dump() functions.
2020-07-02[clang][NFC] Store a pointer to the ASTContext in ASTDumper and TextNodeDumperBruno Ricci
In general there is no way to get to the ASTContext from most AST nodes (Decls are one of the exception). This will be a problem when implementing the rest of APValue::dump since we need the ASTContext to dump some kinds of APValues. The ASTContext* in ASTDumper and TextNodeDumper is not always non-null. This is because we still want to be able to use the various dump() functions in a debugger. No functional changes intended.
2020-06-29[CodeGen] Use the common semantic for fixed-point codegen, not the result ↵Bevin Hansson
semantic. Summary: Using the result semantic is wrong in some cases, such as unsigned fixed-point + signed integer. In this case, the result semantic is unsigned and the common semantic is signed. Reviewers: leonardchan Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D82662
2020-06-27Reland D81869 "Modify FPFeatures to use delta not absolute settings"Melanie Blower
This reverts commit defd43a5b393bb63a902042adf578081b03b171d. with correction to solve msan report To solve https://bugs.llvm.org/show_bug.cgi?id=46166 where the floating point settings in PCH files aren't compatible, rewrite FPFeatures to use a delta in the settings rather than absolute settings. With this patch, these floating point options can be benign. Reviewers: rjmccall Differential Revision: https://reviews.llvm.org/D81869
2020-06-26Revert "Revert "Revert "Modify FPFeatures to use delta not absolute settings"""Melanie Blower
This reverts commit 9518763d710bfbbf9315fa88972c55898be44a0e. Memory sanitizer fails in CGFPOptionsRAII::CGFPOptionsRAII dtor
2020-06-26Revert "Revert "Modify FPFeatures to use delta not absolute settings""Melanie Blower
This reverts commit b55d723ed61052b77e720dcffecac43abe873186. Reapply Modify FPFeatures to use delta not absolute settings To solve https://bugs.llvm.org/show_bug.cgi?id=46166 where the floating point settings in PCH files aren't compatible, rewrite FPFeatures to use a delta in the settings rather than absolute settings. With this patch, these floating point options can be benign. Reviewers: rjmccall Differential Revision: https://reviews.llvm.org/D81869
2020-06-26Revert "Modify FPFeatures to use delta not absolute settings"Melanie Blower
This reverts commit 3a748cbf86cea3844fada04eeff4cc64b01f67e0. I'm reverting this commit because I forgot to format the commit message propertly. Sorry for the thrash.
2020-06-26Modify FPFeatures to use delta not absolute settingsMelanie Blower
2020-06-15attempt to fix failing buildbots after 3bab88b7baa20b276faaee0aa7ca87f636c91877Tyker
Prevent IR-gen from emitting consteval declarations Summary: with this patch instead of emitting calls to consteval function. the IR-gen will emit a store of the already computed result.
2020-06-15Revert "Prevent IR-gen from emitting consteval declarations"Kirill Bobyrev
This reverts commit 3bab88b7baa20b276faaee0aa7ca87f636c91877. This patch causes test failures: http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/17260
2020-06-15Prevent IR-gen from emitting consteval declarationsTyker
Summary: with this patch instead of emitting calls to consteval function. the IR-gen will emit a store of the already computed result. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D76420
2020-06-11[CodeGen] Simplify the way lifetime of block captures is extendedAkira Hatanaka
Rather than pushing inactive cleanups for the block captures at the entry of a full expression and activating them during the creation of the block literal, just call pushLifetimeExtendedDestroy to ensure the cleanups are popped at the end of the scope enclosing the block expression. rdar://problem/63996471 Differential Revision: https://reviews.llvm.org/D81624
2020-06-11Set the LLVM FP optimization flags conservatively.John McCall
Functions can have local pragmas that override the global settings. We set the flags eagerly based on global settings, but if we emit an expression under the influence of a pragma, we clear the appropriate flags from the function. In order to avoid doing a ton of redundant work whenever we emit an FP expression, configure the IRBuilder to default to global settings, and only reconfigure it when we see an FP expression that's not using the global settings. Patch by Michele Scandale! https://reviews.llvm.org/D80462
2020-06-09Reland (again) D80966 [codeview] Put !heapallocsite on calls to operator newArthur Eubanks
Check that getDebugInfo() is not null, as in the first revision, before calling getDebugInfo()->addHeapAllocSiteMetadata(). Else would cause a crash with a new expression in a default arg. --- Clang marks calls to operator new as heap allocation sites, but the operator declared at global scope returns a void pointer. There is no explicit cast in the code, so the compiler has to write down the allocated type itself. Also generalize a cast to use CallBase, so that we mark heap alloc sites when exceptions are enabled. Differential Revision: https://reviews.llvm.org/D80966
2020-06-08Revert "Reland D80966 [codeview] Put !heapallocsite on calls to operator new"Arthur Eubanks
This reverts commit b6e143aa5448bbe29da7b045072e66a31813bced. Causes https://bugs.chromium.org/p/chromium/issues/detail?id=1092370#c5. Will investigate and reland (again).
2020-06-08Reland D80979 [clang] Implement VectorType logic not operatorFangrui Song
With a fix to use -triple %itanium_abi_triple Differential Revision: https://reviews.llvm.org/D80979
2020-06-08Revert "[clang] Implement VectorType logic not operator."Nico Weber
This reverts commit a0de3335edcf19305dad592d21ebe402825184f6. Breaks check-clang on Windows, see e.g. https://reviews.llvm.org/D80979#2078750 (but fails on all other Windows bots too).
2020-06-08[clang] Implement VectorType logic not operator.Jun Ma
Differential Revision: https://reviews.llvm.org/D80979
2020-06-07Reland D80966 [codeview] Put !heapallocsite on calls to operator newFangrui Song
With a change to use `CGM.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo` instead of `getDebugInfo()`, to fix `Profile-<arch> :: instrprof-gcov-multithread_fork.test` See CodeGenModule::CodeGenModule, `EmitGcovArcs || EmitGcovNotes` can set `clang::CodeGen::CodeGenModule::DebugInfo`. --- Clang marks calls to operator new as heap allocation sites, but the operator declared at global scope returns a void pointer. There is no explicit cast in the code, so the compiler has to write down the allocated type itself. Also generalize a cast to use CallBase, so that we mark heap alloc sites when exceptions are enabled. Differential Revision: https://reviews.llvm.org/D80966
2020-06-07[Matrix] Implement * binary operator for MatrixType.Florian Hahn
This patch implements the * binary operator for values of MatrixType. It adds support for matrix * matrix, scalar * matrix and matrix * scalar. For the matrix, matrix case, the number of columns of the first operand must match the number of rows of the second. For the scalar,matrix variants, the element type of the matrix must match the scalar type. Reviewers: rjmccall, anemet, Bigcheese, rsmith, martong Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D76794
2020-06-06Revert "[codeview] Put !heapallocsite on calls to operator new"Douglas Yung
This reverts commit 672ed5386024ba5cee53e19d637b7920a4889837. This commit is hitting an assertion failure across multiple bots in the test: Profile-<arch> :: instrprof-gcov-multithread_fork.test Failing bots include: http://lab.llvm.org:8011/builders/llvm-avr-linux/builds/2205 http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/8967 http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/10789 http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/27750 http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/16751
2020-06-05[codeview] Put !heapallocsite on calls to operator newReid Kleckner
Clang marks calls to operator new as heap allocation sites, but the operator declared at global scope returns a void pointer. There is no explicit cast in the code, so the compiler has to write down the allocated type itself. Also generalize a cast to use CallBase, so that we mark heap alloc sites when exceptions are enabled. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D80966
2020-06-02Support ExtVectorType conditional operatorMin-Yih Hsu
Extension vectors now can be used in element-wise conditional selector. For example: ``` R[i] = C[i]? A[i] : B[i] ``` This feature was previously only enabled in OpenCL C. Now it's also available in C. Not that it has different behaviors than GNU vectors (i.e. __vector_size__). Extension vectors selects on signdness of the vector. GNU vectors on the other hand do normal bool conversions. Also, this feature is not available in C++. Differential Revision: https://reviews.llvm.org/D80574
2020-06-01Fix how cc1 command line options are mapped into FP options.John McCall
Canonicalize on storing FP options in LangOptions instead of redundantly in CodeGenOptions. Incorporate -ffast-math directly into the values of those LangOptions rather than considering it separately when building FPOptions. Build IR attributes from those options rather than a mix of sources. We should really simplify the driver/cc1 interaction here and have the driver pass down options that cc1 directly honors. That can happen in a follow-up, though. Patch by Michele Scandale! https://reviews.llvm.org/D80315
2020-06-01[Matrix] Implement matrix index expressions ([][]).Florian Hahn
This patch implements matrix index expressions (matrix[RowIdx][ColumnIdx]). It does so by introducing a new MatrixSubscriptExpr(Base, RowIdx, ColumnIdx). MatrixSubscriptExprs are built in 2 steps in ActOnMatrixSubscriptExpr. First, if the base of a subscript is of matrix type, we create a incomplete MatrixSubscriptExpr(base, idx, nullptr). Second, if the base is an incomplete MatrixSubscriptExpr, we create a complete MatrixSubscriptExpr(base->getBase(), base->getRowIdx(), idx) Similar to vector elements, it is not possible to take the address of a MatrixSubscriptExpr. For CodeGen, a new MatrixElt type is added to LValue, which is very similar to VectorElt. The only difference is that we may need to cast the type of the base from an array to a vector type when accessing it. Reviewers: rjmccall, anemet, Bigcheese, rsmith, martong Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D76791
2020-06-01[SVE] Eliminate calls to default-false VectorType::get() from ClangChristopher Tetreault
Reviewers: efriedma, david-arm, fpetrogalli, ddunbar, rjmccall Reviewed By: fpetrogalli, rjmccall Subscribers: tschuett, rkruppe, psnobl, dmgreen, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D80323
2020-05-29[Matrix] Implement + and - operators for MatrixType.Florian Hahn
This patch implements the + and - binary operators for values of MatrixType. It adds support for matrix +/- matrix, scalar +/- matrix and matrix +/- scalar. For the matrix, matrix case, the types must initially be structurally equivalent. For the scalar,matrix variants, the element type of the matrix must match the scalar type. Reviewers: rjmccall, anemet, Bigcheese, rsmith, martong Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D76793
2020-05-20[clang] FastMathFlags.allowContract should be initialized only from ↵Melanie Blower
FPFeatures.allowFPContractAcrossStatement Summary: Fix bug introduced in D72841 adding support for pragma float_control Reviewers: rjmccall, Anastasia Differential Revision: https://reviews.llvm.org/D79903
2020-05-04Reapply "Add support for #pragma float_control" with buildbot fixesMelanie Blower
Add support for #pragma float_control Reviewers: rjmccall, erichkeane, sepavloff Differential Revision: https://reviews.llvm.org/D72841 This reverts commit fce82c0ed310174fe48e2402ac731b6340098389.
2020-05-01Revert "Reapply "Add support for #pragma float_control" with improvements to"Melanie Blower
This reverts commit 69aacaf699922ffe0450f567e21208c10c84731f.
2020-05-01Reapply "Add support for #pragma float_control" with improvements toMelanie Blower
test cases Add support for #pragma float_control Reviewers: rjmccall, erichkeane, sepavloff Differential Revision: https://reviews.llvm.org/D72841 This reverts commit 85dc033caccaa6ab919d57f9759290be41240146, and makes corrections to the test cases that failed on buildbots.
2020-05-01Revert "Add support for #pragma float_control"Melanie Blower
This reverts commit 4f1e9a17e9d28bdfd035313c96b3a5d4c91a7733. due to fail on buildbot, sorry for the noise
2020-05-01Add support for #pragma float_controlMelanie Blower
Reviewers: rjmccall, erichkeane, sepavloff Differential Revision: https://reviews.llvm.org/D72841
2020-04-21C++2a -> C++20 in some identifiers; NFC.Aaron Ballman
2020-04-17Reland Implement _ExtInt as an extended int type specifier.Erich Keane
I fixed the LLDB issue, so re-applying the patch. This reverts commit a4b88c044980337bb14390be654fe76864aa60ec.
2020-04-17Revert "Implement _ExtInt as an extended int type specifier."Sterling Augustine
This reverts commit 61ba1481e200b5b35baa81ffcff81acb678e8508. I'm reverting this because it breaks the lldb build with incomplete switch coverage warnings. I would fix it forward, but am not familiar enough with lldb to determine the correct fix. lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:3958:11: error: enumeration values 'DependentExtInt' and 'ExtInt' not handled in switch [-Werror,-Wswitch] switch (qual_type->getTypeClass()) { ^ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4633:11: error: enumeration values 'DependentExtInt' and 'ExtInt' not handled in switch [-Werror,-Wswitch] switch (qual_type->getTypeClass()) { ^ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4889:11: error: enumeration values 'DependentExtInt' and 'ExtInt' not handled in switch [-Werror,-Wswitch] switch (qual_type->getTypeClass()) {
2020-04-17Change users of CreateShuffleVector to pass the masks as int instead of ↵Benjamin Kramer
Constants No functionality change intended.
2020-04-17Implement _ExtInt as an extended int type specifier.Erich Keane
Introduction/Motivation: LLVM-IR supports integers of non-power-of-2 bitwidth, in the iN syntax. Integers of non-power-of-two aren't particularly interesting or useful on most hardware, so much so that no language in Clang has been motivated to expose it before. However, in the case of FPGA hardware normal integer types where the full bitwidth isn't used, is extremely wasteful and has severe performance/space concerns. Because of this, Intel has introduced this functionality in the High Level Synthesis compiler[0] under the name "Arbitrary Precision Integer" (ap_int for short). This has been extremely useful and effective for our users, permitting them to optimize their storage and operation space on an architecture where both can be extremely expensive. We are proposing upstreaming a more palatable version of this to the community, in the form of this proposal and accompanying patch. We are proposing the syntax _ExtInt(N). We intend to propose this to the WG14 committee[1], and the underscore-capital seems like the active direction for a WG14 paper's acceptance. An alternative that Richard Smith suggested on the initial review was __int(N), however we believe that is much less acceptable by WG14. We considered _Int, however _Int is used as an identifier in libstdc++ and there is no good way to fall back to an identifier (since _Int(5) is indistinguishable from an unnamed initializer of a template type named _Int). [0]https://www.intel.com/content/www/us/en/software/programmable/quartus-prime/hls-compiler.html) [1]http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2472.pdf Differential Revision: https://reviews.llvm.org/D73967
2020-04-16LangOptions cannot depend on ASTContext, make it not use ASTContext directlyBenjamin Kramer
Fixes a layering violation introduced in 2ba4e3a4598b165245c581c506a813cd4a7dce33.
2020-04-15Move BinaryOperators.FPOptions to trailing storageMelanie Blower
Reviewers: rjmccall Differential Revision: https://reviews.llvm.org/D76384
2020-04-15Upgrade calls to CreateShuffleVector to use the preferred form of passing an ↵Benjamin Kramer
array of ints No functionality change intended.
2020-04-13Clean up usages of asserting vector getters in TypeChristopher Tetreault
Summary: Remove usages of asserting vector getters in Type in preparation for the VectorType refactor. The existence of these functions complicates the refactor while adding little value. Reviewers: sdesmalen, efriedma, krememek Reviewed By: sdesmalen, efriedma Subscribers: dexonsmith, Charusso, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D77257
2020-04-08[CodeGen] Emit IR for compound assignment with fixed-point operands.Bevin Hansson
Reviewers: rjmccall, leonardchan Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73184
2020-04-08[CodeGen] Emit IR for fixed-point unary operators.Bevin Hansson
Reviewers: rjmccall, leonardchan Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73183
2020-04-08[CodeGen] Emit IR for fixed-point multiplication and division.Bevin Hansson
Reviewers: rjmccall, leonardchan Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73182
2020-03-10[CodeGen] Emit destructor calls to destruct compound literalsAkira Hatanaka
Fix a bug in IRGen where it wasn't destructing compound literals in C that are ObjC pointer arrays or non-trivial structs. Also diagnose jumps that enter or exit the lifetime of the compound literals. rdar://problem/51867864 Differential Revision: https://reviews.llvm.org/D64464