- 
                Notifications
    You must be signed in to change notification settings 
- Fork 15k
RISCV: the builtins support for MIPS RV64 P8700 execution control . #159246
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
          
     Merged
      
      
            ukalappa-mips
  merged 4 commits into
  llvm:main
from
ukalappa-mips:ukalappa_xmipscbop_builtin
  
      
      
   
  Sep 19, 2025 
      
    
  
     Merged
                    Changes from 2 commits
      Commits
    
    
            Show all changes
          
          
            4 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      6e82f23
              
                RISCV: the builtins support for MIPS RV64 P8700 execution control ins…
              
              
                ukalappa-mips fbcef5f
              
                Testcase fix.
              
              
                ukalappa-mips 5525ab5
              
                Updated the changes by adopting the suggestions.
              
              
                ukalappa-mips 9aa3bd3
              
                Added Headers to wrapped around the mips builtins.
              
              
                ukalappa-mips File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| //==- BuiltinsRISCVXMIPS.td - RISC-V MIPS Builtin database ----*- C++ -*-==// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file defines the MIPS-specific builtin function database. Users of | ||
| // this file must define the BUILTIN macro to make use of this information. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|  | ||
| class RISCVXMIPSBuiltin<string prototype, string features = ""> : TargetBuiltin { | ||
| let Spellings = ["__builtin_riscv_" # NAME]; | ||
| let Prototype = prototype; | ||
| let Features = features; | ||
| } | ||
|  | ||
| //===----------------------------------------------------------------------===// | ||
| // MIPS execution control extensions . | ||
|         
                  ukalappa-mips marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| //===----------------------------------------------------------------------===// | ||
| let Attributes = [NoThrow, Const] in { | ||
| def mips_pause : RISCVXMIPSBuiltin<"void()", "xmipsexectl">; | ||
| def mips_ehb : RISCVXMIPSBuiltin<"void()", "xmipsexectl">; | ||
| def mips_ihb : RISCVXMIPSBuiltin<"void()", "xmipsexectl">; | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6 | ||
| // RUN: %clang_cc1 -triple riscv32-linux-elf -O3 -target-feature +xmipsexectl -emit-llvm -o - %s | FileCheck %s | ||
|  | ||
| // CHECK-LABEL: define dso_local void @test_mips_pause( | ||
| // CHECK-SAME: ) local_unnamed_addr #[[ATTR0:[0-9]+]] { | ||
| // CHECK-NEXT: [[ENTRY:.*:]] | ||
| // CHECK-NEXT: tail call void @llvm.riscv.mips.pause() | ||
| // CHECK-NEXT: ret void | ||
| // | ||
| void test_mips_pause() | ||
| { | ||
| __builtin_riscv_mips_pause(); | ||
|         
                  wangpc-pp marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| } | ||
|  | ||
| // CHECK-LABEL: define dso_local void @test_mips_ehb( | ||
| // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] { | ||
| // CHECK-NEXT: [[ENTRY:.*:]] | ||
| // CHECK-NEXT: tail call void @llvm.riscv.mips.ehb() | ||
| // CHECK-NEXT: ret void | ||
| // | ||
| void test_mips_ehb() | ||
| { | ||
| __builtin_riscv_mips_ehb(); | ||
| } | ||
|  | ||
| // CHECK-LABEL: define dso_local void @test_mips_ihb( | ||
| // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] { | ||
| // CHECK-NEXT: [[ENTRY:.*:]] | ||
| // CHECK-NEXT: tail call void @llvm.riscv.mips.ihb() | ||
| // CHECK-NEXT: ret void | ||
| // | ||
| void test_mips_ihb() | ||
| { | ||
| __builtin_riscv_mips_ihb(); | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===- IntrinsicsRISCVXMIPS.td - Defines MIPS intrinsics -------*- tablegen -*-===// | ||
|         
                  ukalappa-mips marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file defines all of the MIPS specific intrinsics for RISCV. | ||
|         
                  ukalappa-mips marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|  | ||
| let TargetPrefix = "riscv" in { | ||
| def int_riscv_mips_pause : ClangBuiltin<"__builtin_riscv_mips_pause">, | ||
| Intrinsic<[], [], [IntrNoMem, IntrHasSideEffects]>; | ||
| def int_riscv_mips_ehb : ClangBuiltin<"__builtin_riscv_mips_ehb">, | ||
| Intrinsic<[], [], [IntrNoMem, IntrHasSideEffects]>; | ||
| def int_riscv_mips_ihb : ClangBuiltin<"__builtin_riscv_mips_ihb">, | ||
| Intrinsic<[], [], [IntrNoMem, IntrHasSideEffects]>; | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --tool /home/ukalappa/llvm/github/build/bin/llc --version 6 | ||
|         
                  ukalappa-mips marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| ; RUN: llc -mtriple=riscv64 -mcpu=mips-p8700 -O3 -verify-machineinstrs < %s \ | ||
| ; RUN: | FileCheck -check-prefix=MIPS %s | ||
|  | ||
| target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" | ||
|  | ||
| define dso_local void @test_mips_pause() local_unnamed_addr { | ||
|         
                  ukalappa-mips marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| ; MIPS-LABEL: test_mips_pause: | ||
| ; MIPS: # %bb.0: # %entry | ||
| ; MIPS-NEXT: mips.pause | ||
| ; MIPS-NEXT: ret | ||
| entry: | ||
| tail call void @llvm.riscv.mips.pause() | ||
| ret void | ||
| } | ||
|  | ||
| define dso_local void @test_mips_ehb() local_unnamed_addr { | ||
| ; MIPS-LABEL: test_mips_ehb: | ||
| ; MIPS: # %bb.0: # %entry | ||
| ; MIPS-NEXT: mips.ehb | ||
| ; MIPS-NEXT: ret | ||
| entry: | ||
| tail call void @llvm.riscv.mips.ehb() | ||
| ret void | ||
| } | ||
|  | ||
| define dso_local void @test_mips_ihb() local_unnamed_addr { | ||
| ; MIPS-LABEL: test_mips_ihb: | ||
| ; MIPS: # %bb.0: # %entry | ||
| ; MIPS-NEXT: mips.ihb | ||
| ; MIPS-NEXT: ret | ||
| entry: | ||
| tail call void @llvm.riscv.mips.ihb() | ||
| ret void | ||
| } | ||
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.