loongarch support (#30)
This commit is contained in:
		
							parent
							
								
									1831bf381e
								
							
						
					
					
						commit
						b263bf6d65
					
				| @ -6,7 +6,7 @@ | |||||||
| Detect CPU ISA features with single-file | Detect CPU ISA features with single-file | ||||||
| 
 | 
 | ||||||
| <table> | <table> | ||||||
| <tr><td>CPU</td><td>✅ x86, x86-64<br/>✅ arm, aarch64<br/>✅ mips<br/>✅ powerpc<br/>✅ s390x<br/>✅ risc-v</td><td rowspan=3> | <tr><td>CPU</td><td>✅ x86, x86-64<br/>✅ arm, aarch64<br/>✅ mips<br/>✅ powerpc<br/>✅ s390x<br/>✅ risc-v<br/>✅ loongarch</td><td rowspan=3> | ||||||
|    |    | ||||||
| ```c | ```c | ||||||
| #define RUAPU_IMPLEMENTATION | #define RUAPU_IMPLEMENTATION | ||||||
| @ -223,7 +223,7 @@ _`fma4` on zen1, ISA in hypervisor, etc._ | |||||||
| |mips|`msa`| | |mips|`msa`| | ||||||
| |powerpc|`vsx`| | |powerpc|`vsx`| | ||||||
| |s390x|`zvector`| | |s390x|`zvector`| | ||||||
| |loongarch|| | |loongarch|`lsx` `lasx`| | ||||||
| |risc-v|`i` `m` `a` `f` `d` `c`| | |risc-v|`i` `m` `a` `f` `d` `c`| | ||||||
| 
 | 
 | ||||||
| ## Techniques inside ruapu | ## Techniques inside ruapu | ||||||
|  | |||||||
							
								
								
									
										4
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								main.c
									
									
									
									
									
								
							| @ -87,6 +87,10 @@ int main() | |||||||
|     PRINT_ISA_SUPPORT(d) |     PRINT_ISA_SUPPORT(d) | ||||||
|     PRINT_ISA_SUPPORT(c) |     PRINT_ISA_SUPPORT(c) | ||||||
| 
 | 
 | ||||||
|  | #elif __loongarch__ | ||||||
|  |     PRINT_ISA_SUPPORT(lsx) | ||||||
|  |     PRINT_ISA_SUPPORT(lasx) | ||||||
|  | 
 | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|     return 0; |     return 0; | ||||||
|  | |||||||
							
								
								
									
										10
									
								
								ruapu.h
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								ruapu.h
									
									
									
									
									
								
							| @ -136,7 +136,7 @@ static int ruapu_detect_isa(ruapu_some_inst some_inst) | |||||||
| 
 | 
 | ||||||
| #if defined(__i386__) || defined(__x86_64__) || __s390x__ | #if defined(__i386__) || defined(__x86_64__) || __s390x__ | ||||||
| #define RUAPU_INSTCODE(isa, ...) static void ruapu_some_##isa() { asm volatile(".byte " #__VA_ARGS__ : : : ); } | #define RUAPU_INSTCODE(isa, ...) static void ruapu_some_##isa() { asm volatile(".byte " #__VA_ARGS__ : : : ); } | ||||||
| #elif __aarch64__ || __arm__ || __mips__ || __riscv | #elif __aarch64__ || __arm__ || __mips__ || __riscv || __loongarch__ | ||||||
| #define RUAPU_INSTCODE(isa, ...) static void ruapu_some_##isa() { asm volatile(".word " #__VA_ARGS__ : : : ); } | #define RUAPU_INSTCODE(isa, ...) static void ruapu_some_##isa() { asm volatile(".word " #__VA_ARGS__ : : : ); } | ||||||
| #elif __powerpc__ | #elif __powerpc__ | ||||||
| #define RUAPU_INSTCODE(isa, ...) static void ruapu_some_##isa() { asm volatile(".long " #__VA_ARGS__ : : : ); } | #define RUAPU_INSTCODE(isa, ...) static void ruapu_some_##isa() { asm volatile(".long " #__VA_ARGS__ : : : ); } | ||||||
| @ -240,6 +240,10 @@ RUAPU_INSTCODE(f, 0x10a57553) // fmul.s fa0,fa0,fa0 | |||||||
| RUAPU_INSTCODE(d, 0x12a57553) // fmul.d fa0,fa0,fa0
 | RUAPU_INSTCODE(d, 0x12a57553) // fmul.d fa0,fa0,fa0
 | ||||||
| RUAPU_INSTCODE(c, 0x0001952a) // add a0,a0,a0 + nop
 | RUAPU_INSTCODE(c, 0x0001952a) // add a0,a0,a0 + nop
 | ||||||
| 
 | 
 | ||||||
|  | #elif __loongarch__ | ||||||
|  | RUAPU_INSTCODE(lsx, 0x700b0000) //vadd.w vr0, vr0, vr0
 | ||||||
|  | RUAPU_INSTCODE(lasx, 0x740b0000) //xvadd.w xr0, xr0, xr0
 | ||||||
|  | 
 | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #undef RUAPU_INSTCODE | #undef RUAPU_INSTCODE | ||||||
| @ -320,6 +324,10 @@ RUAPU_ISAENTRY(f) | |||||||
| RUAPU_ISAENTRY(d) | RUAPU_ISAENTRY(d) | ||||||
| RUAPU_ISAENTRY(c) | RUAPU_ISAENTRY(c) | ||||||
| 
 | 
 | ||||||
|  | #elif __loongarch__ | ||||||
|  | RUAPU_ISAENTRY(lsx) | ||||||
|  | RUAPU_ISAENTRY(lasx) | ||||||
|  | 
 | ||||||
| #endif | #endif | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user