-
Notifications
You must be signed in to change notification settings - Fork 14.3k
TableGen: Allow defining sets of runtime libraries #144978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e45223b
6bf7e89
dca0764
bdb45ae
233b93e
e8bef95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//===- SetTheory.td - DAG set operator declarations --------*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// FIXME: This is not used everywhere, and different files declare | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this file used for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Declaring the recognized dag operators. These have always been "forward declared" in tablegen, but that's not actually a feature tablegen has |
||
// different subsets of used operators. | ||
// | ||
// It just happens TargetSelectionDAG.td defines records with the same | ||
// names as the tablegen DAG operators for SelectionDAG operators. | ||
|
||
// Target.td separately declares the special set operators. | ||
|
||
def add; // Forward declare | ||
def sub; | ||
def and; | ||
def shl; | ||
// def trunc; // FIXME: Name collision | ||
def rotl; | ||
def rotr; | ||
|
||
def sequence; | ||
def decimate; | ||
def interleave; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// RUN: not llvm-tblgen -gen-runtime-libcalls -I %p/../../include %s 2>&1 | FileCheck %s | ||
|
||
include "llvm/IR/RuntimeLibcallsImpl.td" | ||
|
||
def SOME_FUNC : RuntimeLibcall; | ||
def func_a : RuntimeLibcallImpl<SOME_FUNC>; | ||
|
||
def isTargetArchA : RuntimeLibcallPredicate<[{isTargetArchA()}]>; | ||
|
||
// CHECK: [[@LINE+4]]:5: error: entry for SystemLibrary is not a RuntimeLibcallImpl | ||
// CHECK-NEXT: def TheSystemLibraryA : SystemRuntimeLibrary<isTargetArchA, | ||
// CHECK: note: invalid entry `SOME_FUNC` | ||
// CHECK-NEXT: def SOME_FUNC : RuntimeLibcall; | ||
def TheSystemLibraryA : SystemRuntimeLibrary<isTargetArchA, | ||
(add SOME_FUNC) | ||
>; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// RUN: llvm-tblgen -gen-runtime-libcalls -I %p/../../include %s 2> %t.err | FileCheck %s | ||
// RUN: FileCheck -check-prefix=ERR %s < %t.err | ||
|
||
// Check behavior of libcall emission when multiple RuntimeLibcallImpl | ||
// implementations provide the same RuntimeLibcall | ||
|
||
include "llvm/IR/RuntimeLibcallsImpl.td" | ||
|
||
def SOME_FUNC : RuntimeLibcall; | ||
def OTHER_FUNC : RuntimeLibcall; | ||
def ANOTHER_DUP : RuntimeLibcall; | ||
|
||
def isTargetArchA : RuntimeLibcallPredicate<[{isTargetArchA()}]>; | ||
def isTargetArchB : RuntimeLibcallPredicate<[{isTargetArchB()}]>; | ||
def isTargetArchC : RuntimeLibcallPredicate<[{isTargetArchC()}]>; | ||
|
||
def func_a : RuntimeLibcallImpl<SOME_FUNC>; | ||
def func_b : RuntimeLibcallImpl<SOME_FUNC>; | ||
def func_c : RuntimeLibcallImpl<SOME_FUNC>; | ||
def other_func : RuntimeLibcallImpl<OTHER_FUNC>; | ||
|
||
def dup0 : RuntimeLibcallImpl<ANOTHER_DUP>; | ||
def dup1 : RuntimeLibcallImpl<ANOTHER_DUP>; | ||
|
||
// func_a and func_b both provide SOME_FUNC. | ||
|
||
// CHECK: if (isTargetArchA()) { | ||
// CHECK-NEXT: static const LibcallImplPair LibraryCalls[] = { | ||
// CHECK-NEXT: {RTLIB::SOME_FUNC, RTLIB::func_b}, // func_b | ||
// CHECK-NEXT: }; | ||
|
||
// ERR: :[[@LINE+1]]:5: warning: conflicting implementations for libcall SOME_FUNC: func_b, func_a | ||
def TheSystemLibraryA : SystemRuntimeLibrary<isTargetArchA, | ||
(add func_b, func_a) | ||
>; | ||
|
||
// CHECK: if (isTargetArchB()) { | ||
// CHECK-NEXT: static const LibcallImplPair LibraryCalls[] = { | ||
// CHECK-NEXT: {RTLIB::OTHER_FUNC, RTLIB::other_func}, // other_func | ||
// CHECK-NEXT: {RTLIB::SOME_FUNC, RTLIB::func_a}, // func_a | ||
// CHECK-NEXT: }; | ||
|
||
// ERR: :[[@LINE+1]]:5: warning: conflicting implementations for libcall SOME_FUNC: func_a, func_b | ||
def TheSystemLibraryB : SystemRuntimeLibrary<isTargetArchB, | ||
(add func_a, other_func, func_b) | ||
>; | ||
|
||
// CHECK: if (isTargetArchC()) { | ||
// CHECK-NEXT: static const LibcallImplPair LibraryCalls[] = { | ||
// CHECK-NEXT: {RTLIB::ANOTHER_DUP, RTLIB::dup1}, // dup1 | ||
// CHECK-NEXT: {RTLIB::OTHER_FUNC, RTLIB::other_func}, // other_func | ||
// CHECK-NEXT: {RTLIB::SOME_FUNC, RTLIB::func_a}, // func_a | ||
// CHECK-NEXT: }; | ||
|
||
// ERR: :[[@LINE+3]]:5: warning: conflicting implementations for libcall ANOTHER_DUP: dup1, dup0 | ||
// ERR: :[[@LINE+2]]:5: warning: conflicting implementations for libcall SOME_FUNC: func_a, func_b | ||
// ERR: :[[@LINE+1]]:5: warning: conflicting implementations for libcall SOME_FUNC: func_a, func_c | ||
def TheSystemLibraryC : SystemRuntimeLibrary<isTargetArchC, | ||
(add func_a, dup1, other_func, func_b, func_c, dup0) | ||
>; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// RUN: not llvm-tblgen -gen-runtime-libcalls -I %p/../../include %s 2>&1 | FileCheck -check-prefix=ERR %s | ||
|
||
include "llvm/IR/RuntimeLibcallsImpl.td" | ||
|
||
def FUNC0 : RuntimeLibcall; | ||
def FUNC1 : RuntimeLibcall; | ||
|
||
def isFoo : RuntimeLibcallPredicate<[{isFoo()}]>; | ||
def isBar : RuntimeLibcallPredicate<[{isBar()}]>; | ||
def isTargetArch : RuntimeLibcallPredicate<[{isTargetArch()}]>; | ||
|
||
def func0 : RuntimeLibcallImpl<FUNC0>; | ||
def func1 : RuntimeLibcallImpl<FUNC1>; | ||
|
||
// ERR: :[[@LINE+2]]:8: error: combining nested libcall set predicates currently unhandled | ||
def TheSystemLibrary : SystemRuntimeLibrary<isTargetArch, | ||
(add LibcallImpls<(add func0, LibcallImpls<(add func1), isBar>), isFoo>) | ||
>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking, this is fixed in one of your later PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes