Created
August 29, 2019 09:07
-
-
Save AllanChen/ea2123c59f11871e76efa2d3d48dcea2 to your computer and use it in GitHub Desktop.
NEON INT 16 command test
This file contains 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
#import "AppDelegate.h" | |
@interface AppDelegate () | |
@end | |
@implementation AppDelegate | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
[self neonCommandTest]; | |
return YES; | |
} | |
- (void)neonCommandTest{ | |
uint16_t *ptr = new uint16_t[100](); | |
for (int i=0; i<100; i++){ | |
ptr[i] = (uint16_t)i; | |
} | |
int nn = 1; | |
uint16_t *output = new uint16_t[100](); | |
#if __ARM_NEON | |
#if __aarch64__ | |
if(nn > 0){ | |
asm volatile( | |
"0: \n" | |
"prfm pldl1keep, [%1, #64] \n" | |
// "ld1 {v0.4s, v1.4s}, [%1], #32 \n" | |
"ld2 {v0.8h,v1.8h}, [%1], #32 \n" | |
"trn1 v1.4s, v1.4s, v1.4s \n " | |
"subs %w0, %w0, #1 \n" | |
"st1 {v4.4s}, [%2], #16 \n" | |
"bne 0b \n" | |
: | |
"=r"(nn), //%0 | |
"=r"(ptr), //%1 | |
"=r"(output) //%2 | |
: | |
"0"(nn), | |
"1"(ptr), | |
"2"(output) | |
: "cc","memory","v0","v1","v4" | |
); | |
} | |
#else | |
asm volatile( | |
"0: \n" | |
"vld1.s16 {q1}, [%1] \n" | |
"vtrn.16 d0, d1 \n " | |
"subs %0, #1 \n" | |
// "st1 {v2.4s}, [%2], #16 \n" | |
"bne 0b \n" | |
: | |
"=r"(nn), //%0 | |
"=r"(ptr), //%1 | |
"=r"(output) //%2 | |
: | |
"0"(nn), | |
"1"(ptr), | |
"2"(output) | |
: "cc","memory","q1","q2" | |
); | |
#endif | |
- (void)applicationWillResignActive:(UIApplication *)application { | |
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | |
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. | |
} | |
- (void)applicationDidEnterBackground:(UIApplication *)application { | |
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | |
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | |
} | |
- (void)applicationWillEnterForeground:(UIApplication *)application { | |
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. | |
} | |
- (void)applicationDidBecomeActive:(UIApplication *)application { | |
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | |
} | |
- (void)applicationWillTerminate:(UIApplication *)application { | |
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment